Skip to content

Commit c1b16c8

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 c1b16c8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/test_copies_or_views.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,15 @@ 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+
if xp_name == 'array_api_strict' and xp.__version__ < "2.5":
72+
# https://github.com/data-apis/array-api-strict/pull/180
73+
pytest.xfail("clip(x) was only fixed in -strict == 2.5")
74+
75+
x = xp.arange(8)
76+
assert not is_view(xp.clip, x, 42)

0 commit comments

Comments
 (0)