Copilot commented on code in PR #54690:
URL: https://github.com/apache/arrow/pull/54690#discussion_r4601084712
##########
python/pyarrow/tests/test_dlpack.py:
##########
@@ -268,6 +268,8 @@ def immutable_tensor():
@check_bytes_allocated
@pytest.mark.parametrize('max_version', [None, (0, 8)])
+# Filter deprecation warning, already asserted in test_dlpack_legacy_capsule
[email protected]("ignore: Exporting an unversioned DLPack")
Review Comment:
The filter string includes a leading space after `ignore:` (`"ignore:
Exporting..."`), while other filters in this file match `"ignore:Exporting..."`
(no space). Since `filterwarnings` matches the warning message via regex, this
extra space can prevent the filter from matching and would defeat the PR’s
purpose (warnings still emitted/failing CI). Remove the extra space and
consider making the filter consistent with the more explicit pattern used below
(including the warning category).
##########
python/pyarrow/tests/test_dlpack.py:
##########
@@ -331,28 +334,38 @@ def test_dlpack_copy_is_writeable():
assert arr.to_pylist() == [1, 2, 3]
+def from_dlpack_split(obj):
+ if Version(np.__version__) < Version("2.1.0"):
+ max_version = None
+ else:
+ max_version = (1, 0)
+ return np.from_dlpack(DLPackForwarder(obj, max_version=max_version))
Review Comment:
The NumPy version check runs every time the helper is invoked (including
multiple calls within a single test). Since this is deterministic for the test
session, consider computing the boolean (or chosen `max_version`) once at
module scope and reusing it in the helper. This reduces repeated parsing and
keeps the helper focused on the `np.from_dlpack` call.
##########
python/pyarrow/tests/test_dlpack.py:
##########
@@ -306,6 +308,7 @@ def test_dlpack_versioned_capsule(obj, max_version, copy):
@requires_numpy_version("2.1.0")
@check_bytes_allocated
@pytest.mark.parametrize('obj', dlpack_objects())
[email protected]("ignore: Exporting an unversioned DLPack")
Review Comment:
This warning filter is broad because it omits the warning category (and
optionally module). To avoid accidentally masking unrelated warnings with
similar messages, prefer specifying the category (as done later in the file),
e.g., including `:DeprecationWarning` in the filter string.
##########
python/pyarrow/tests/test_dlpack.py:
##########
@@ -331,28 +334,38 @@ def test_dlpack_copy_is_writeable():
assert arr.to_pylist() == [1, 2, 3]
+def from_dlpack_split(obj):
+ if Version(np.__version__) < Version("2.1.0"):
+ max_version = None
+ else:
+ max_version = (1, 0)
+ return np.from_dlpack(DLPackForwarder(obj, max_version=max_version))
Review Comment:
`from_dlpack_split` is not very descriptive about what is being “split”
(it’s selecting a `max_version` based on NumPy version). Consider renaming to
something that reflects intent, e.g. `from_dlpack_compat`,
`from_dlpack_with_versioned_export`, or `from_dlpack_numpy_compat`, to make the
tests easier to read/maintain.
--
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]