rok commented on code in PR #42118:
URL: https://github.com/apache/arrow/pull/42118#discussion_r2077400941
##########
python/pyarrow/tests/test_dlpack.py:
##########
@@ -103,6 +101,30 @@ def test_dlpack(value_type, np_type_str):
expected = np.array([], dtype=np.dtype(np_type_str))
check_dlpack_export(arr_zero, expected)
+ t = pa.Tensor.from_numpy(expected)
+ check_dlpack_export(t, expected)
+
+
+@check_bytes_allocated
[email protected]('np_type',
+ [np.uint8, np.uint16, np.uint32, np.uint64,
+ np.int8, np.int16, np.int32, np.int64,
+ np.float16, np.float32, np.float64,])
+def test_tensor_dlpack(np_type):
+ if Version(np.__version__) < Version("1.24.0"):
+ pytest.skip("No dlpack support in numpy versions older than 1.22.0, "
+ "strict keyword in assert_array_equal added in numpy
version "
+ "1.24.0")
+
+ arr = np.array([1, 2, 3, 4, 5, 6, 1, 1])
+ expected = np.ndarray((2, 2, 2), dtype=np_type, buffer=arr)
Review Comment:
Nit: oddly [numpy doesn't specify what the default order
is](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy-ndarray),
so how about:
```suggestion
expected = np.ndarray((2, 2, 2), dtype=np_type, buffer=arr, order='C')
```
--
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]