Copilot commented on code in PR #50203:
URL: https://github.com/apache/arrow/pull/50203#discussion_r3426986690
##########
python/pyarrow/tests/test_array.py:
##########
@@ -2924,6 +2924,24 @@ def test_array_from_invalid_dim_raises():
pa.array(arr0d)
[email protected]
+def test_fixed_size_list_from_multidim_ndarray():
+ # GH-49644: a fixed-size list can be built from multi-dimensional ndarray
+ # elements by flattening them in C order.
+ arr = pa.array([np.array([[1, 2, 3]]), np.array([[4, 5, 6]])],
+ type=pa.list_(pa.int64(), 3))
Review Comment:
These `np.array(...)` calls rely on NumPy’s default integer dtype, which can
vary by platform/architecture. To keep the test deterministic, explicitly set
`dtype=np.int64` for the NumPy arrays used to build a `pa.int64()` fixed-size
list.
##########
python/pyarrow/tests/test_array.py:
##########
@@ -2924,6 +2924,24 @@ def test_array_from_invalid_dim_raises():
pa.array(arr0d)
[email protected]
+def test_fixed_size_list_from_multidim_ndarray():
+ # GH-49644: a fixed-size list can be built from multi-dimensional ndarray
+ # elements by flattening them in C order.
+ arr = pa.array([np.array([[1, 2, 3]]), np.array([[4, 5, 6]])],
+ type=pa.list_(pa.int64(), 3))
+ assert arr.type == pa.list_(pa.int64(), 3)
+ assert arr.to_pylist() == [[1, 2, 3], [4, 5, 6]]
Review Comment:
The test currently only exercises a (1, 3) shaped input, where C-order
flattening is effectively the same as reading the row. To validate the new
multi-dimensional flattening behavior more robustly, add an assertion using a
non-trivial 2D shape (e.g., (2, 2) into a fixed-size list of 4) to confirm the
produced list follows C-order flattening.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]