Skip to content

Commit 4d591d0

Browse files
committed
Handle large Python integers better in clip
1 parent 398fdf1 commit 4d591d0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

array_api_compat/common/_aliases.py

+9
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,15 @@ def _isscalar(a):
301301

302302
# but an answer of 0 might be preferred. See
303303
# https://github.com/numpy/numpy/issues/24976 for more discussion on this issue.
304+
305+
306+
# At least handle the case of Python integers correctly (see
307+
# https://github.com/numpy/numpy/pull/26892).
308+
if type(min) is int and min <= xp.iinfo(x.dtype).min:
309+
min = None
310+
if type(max) is int and max >= xp.iinfo(x.dtype).max:
311+
max = None
312+
304313
if out is None:
305314
out = wrapped_xp.asarray(xp.broadcast_to(x, result_shape), copy=True)
306315
if min is not None:

0 commit comments

Comments
 (0)