Skip to content

Commit b940c19

Browse files
committed
Revert "BUG: clip() should not have out= parameter"
This reverts commit d59344c.
1 parent d59344c commit b940c19

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

array_api_compat/common/_aliases.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ def clip(
331331
max: Optional[Union[int, float, ndarray]] = None,
332332
*,
333333
xp,
334+
# TODO: np.clip has other ufunc kwargs
335+
out: Optional[ndarray] = None,
334336
) -> ndarray:
335337
def _isscalar(a):
336338
return isinstance(a, (int, float, type(None)))
@@ -366,9 +368,9 @@ def _isscalar(a):
366368
if type(max) is int and max >= wrapped_xp.iinfo(x.dtype).max:
367369
max = None
368370

369-
out = wrapped_xp.asarray(xp.broadcast_to(x, result_shape),
370-
copy=True, device=device(x))
371-
371+
if out is None:
372+
out = wrapped_xp.asarray(xp.broadcast_to(x, result_shape),
373+
copy=True, device=device(x))
372374
if min is not None:
373375
if is_torch_array(x) and x.dtype == xp.float64 and _isscalar(min):
374376
# Avoid loss of precision due to torch defaulting to float32

0 commit comments

Comments
 (0)