Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion array_api_strict/_elementwise_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def clip(
raise TypeError("Only real numeric dtypes are allowed in clip")

if min is max is None:
return x
return Array._new(x._array.copy(), device=x.device)

for argname, arg in ("min", min), ("max", max):
if isinstance(arg, Array):
Expand Down
9 changes: 9 additions & 0 deletions array_api_strict/tests/test_elementwise_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,12 @@ def _array_vals():

with pytest.raises(TypeError):
func(s, s)


def test_clip_none():
# regression test: clip(x) is a copy of x, not a view
x = asarray([1, 2, 3])
y = array_api_strict.clip(x)

y[1] = 42
assert x[1] == 2
Loading