@@ -1733,7 +1733,6 @@ def test_tensor_array_from_numpy(np_type_str):
17331733@pytest .mark .numpy
17341734@pytest .mark .parametrize ("np_type_str" , ("int8" , "int64" , "float32" ))
17351735def test_tensor_array_from_list_of_ndarrays (np_type_str ):
1736- # GH-49644
17371736 np_dtype = np .dtype (np_type_str )
17381737 tensor_type = pa .fixed_shape_tensor (pa .from_numpy_dtype (np_dtype ), (2 , 3 ))
17391738
@@ -1746,33 +1745,25 @@ def test_tensor_array_from_list_of_ndarrays(np_type_str):
17461745 assert result .type == tensor_type
17471746 assert len (result ) == 2
17481747
1749- # Must match the existing from_numpy_ndarray path on the same data
17501748 expected = pa .FixedShapeTensorArray .from_numpy_ndarray (np .stack (elements ))
17511749 assert result .storage .equals (expected .storage )
17521750
1753- # Each element round-trips back to the original ndarray (with its shape)
17541751 for scalar , original in zip (result , elements ):
17551752 np .testing .assert_array_equal (scalar .to_numpy (), original )
17561753
1757- # Higher-dimensional tensors work too
17581754 tensor_3d = pa .fixed_shape_tensor (pa .from_numpy_dtype (np_dtype ), (2 , 2 , 3 ))
17591755 elements_3d = [np .arange (12 , dtype = np_dtype ).reshape (2 , 2 , 3 )]
17601756 result_3d = pa .array (elements_3d , type = tensor_3d )
17611757 assert result_3d .type == tensor_3d
17621758 np .testing .assert_array_equal (result_3d [0 ].to_numpy (), elements_3d [0 ])
17631759
1764- # None elements are allowed
17651760 result_with_null = pa .array ([elements [0 ], None ], type = tensor_type )
17661761 assert result_with_null .null_count == 1
17671762 assert result_with_null [1 ].as_py () is None
17681763
1769- # A multi-dimensional element whose shape doesn't match the tensor shape is
1770- # rejected, even when the total number of elements is the same (GH-49644).
17711764 with pytest .raises (ValueError , match = "shape" ):
17721765 pa .array ([np .arange (6 , dtype = np_dtype ).reshape (3 , 2 )], type = tensor_type )
17731766
1774- # Permuted tensor types can't be built from a sequence (the flatten would
1775- # store the wrong layout), so they're rejected for now.
17761767 permuted_type = pa .fixed_shape_tensor (
17771768 pa .from_numpy_dtype (np_dtype ), (2 , 3 ), permutation = [1 , 0 ])
17781769 with pytest .raises (NotImplementedError , match = "permutation" ):
@@ -1781,8 +1772,8 @@ def test_tensor_array_from_list_of_ndarrays(np_type_str):
17811772
17821773@pytest .mark .numpy
17831774def test_tensor_array_from_list_mixed_layout ():
1784- # GH-49644: C- and F-ordered arrays with the same values must produce the
1785- # same result, since the values are always flattened in C order.
1775+ # C- and F-ordered arrays with the same values must produce the same
1776+ # result, since the values are always flattened in C order.
17861777 tensor_type = pa .fixed_shape_tensor (pa .int64 (), (2 , 3 ))
17871778 raw = [[1 , 2 , 3 ], [4 , 5 , 6 ]]
17881779 c_arr = np .array (raw , order = "C" )
@@ -1798,7 +1789,6 @@ def test_tensor_array_from_list_mixed_layout():
17981789
17991790@pytest .mark .numpy
18001791def test_tensor_array_from_list_of_0d_arrays ():
1801- # GH-49644: a scalar (0-dimensional) tensor can be built from 0-D arrays.
18021792 tensor_type = pa .fixed_shape_tensor (pa .int64 (), ())
18031793 result = pa .array ([np .array (1 , dtype = np .int64 ), np .array (2 , dtype = np .int64 )],
18041794 type = tensor_type )
0 commit comments