Skip to content

Commit 1c3968b

Browse files
committed
TST: test that clip(x) returns a copy not a view
The spec only says that "If both min and max are None, the elements of the returned array must equal the respective elements in x" Bare NumPy 2.x and CuPy 13.x return copes: >>> x = np.arange(8); np.may_share_memory(x, np.clip(x)) False Thus assume that all wrapped libraries should return a copy, too. Add a test to this effect.
1 parent dd6d3e8 commit 1c3968b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/test_copies_or_views.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,11 @@ def test_view_or_copy(inputs, xp_name):
6262
is_view_wrapped = is_view(wrapped_func, a1, value)
6363

6464
assert is_view_bare == is_view_wrapped
65+
66+
67+
@pytest.mark.parametrize('xp_name', wrapped_libraries + ['array_api_strict'])
68+
def test_clip_none(xp_name):
69+
xp = import_(xp_name, wrapper=True)
70+
71+
x = xp.arange(8)
72+
assert not is_view(xp.clip, x, 42)

0 commit comments

Comments
 (0)