@@ -1651,19 +1651,28 @@ def transpose_homogeneous_masked_arrays(
1651
1651
same dtype. The caller is responsible for ensuring validity of input data.
1652
1652
"""
1653
1653
masked_arrays = list (masked_arrays )
1654
+ dtype = masked_arrays [0 ].dtype
1655
+
1654
1656
values = [arr ._data .reshape (1 , - 1 ) for arr in masked_arrays ]
1655
- transposed_values = np .concatenate (values , axis = 0 )
1657
+ transposed_values = np .concatenate (
1658
+ values ,
1659
+ axis = 0 ,
1660
+ out = np .empty (
1661
+ (len (masked_arrays ), len (masked_arrays [0 ])),
1662
+ order = "F" ,
1663
+ dtype = dtype .numpy_dtype ,
1664
+ ),
1665
+ )
1656
1666
1657
1667
masks = [arr ._mask .reshape (1 , - 1 ) for arr in masked_arrays ]
1658
- transposed_masks = np .concatenate (masks , axis = 0 )
1668
+ transposed_masks = np .concatenate (
1669
+ masks , axis = 0 , out = np .empty_like (transposed_values , dtype = bool )
1670
+ )
1659
1671
1660
- dtype = masked_arrays [0 ].dtype
1661
1672
arr_type = dtype .construct_array_type ()
1662
1673
transposed_arrays : list [BaseMaskedArray ] = []
1663
1674
for i in range (transposed_values .shape [1 ]):
1664
- transposed_arr = arr_type (
1665
- transposed_values [:, i ].copy (), mask = transposed_masks [:, i ].copy ()
1666
- )
1675
+ transposed_arr = arr_type (transposed_values [:, i ], mask = transposed_masks [:, i ])
1667
1676
transposed_arrays .append (transposed_arr )
1668
1677
1669
1678
return transposed_arrays
0 commit comments