Skip to content

Commit 052d387

Browse files
committed
reduce diff size
1 parent 1d88ff9 commit 052d387

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

array_api_strict/_elementwise_functions.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -230,22 +230,6 @@ def wrapper(x: Array, /) -> Array:
230230
trunc = _identity_if_integer(_create_unary_func("trunc", "real numeric"))
231231

232232

233-
def sign(x: Array, /) -> Array:
234-
"""
235-
Array API compatible wrapper for :py:func:`np.sign <numpy.sign>`.
236-
237-
See its docstring for more information.
238-
"""
239-
if not isinstance(x, Array):
240-
raise TypeError(f"Only Array objects are allowed; got {type(x)}")
241-
if x.dtype not in _numeric_dtypes:
242-
raise TypeError("Only numeric dtypes are allowed in sign")
243-
# Special treatment to work around non-compliant NumPy 1.x behaviour
244-
if x.dtype in _complex_floating_dtypes:
245-
return x/abs(x)
246-
return Array._new(np.sign(x._array), device=x.device)
247-
248-
249233
# Note: min and max argument names are different and not optional in numpy.
250234
@requires_api_version('2023.12')
251235
def clip(
@@ -349,3 +333,19 @@ def _isscalar(a):
349333
ib = (out > b) | np.isnan(b)
350334
out[ib] = b[ib]
351335
return Array._new(out, device=device)
336+
337+
338+
def sign(x: Array, /) -> Array:
339+
"""
340+
Array API compatible wrapper for :py:func:`np.sign <numpy.sign>`.
341+
342+
See its docstring for more information.
343+
"""
344+
if not isinstance(x, Array):
345+
raise TypeError(f"Only Array objects are allowed; got {type(x)}")
346+
if x.dtype not in _numeric_dtypes:
347+
raise TypeError("Only numeric dtypes are allowed in sign")
348+
# Special treatment to work around non-compliant NumPy 1.x behaviour
349+
if x.dtype in _complex_floating_dtypes:
350+
return x/abs(x)
351+
return Array._new(np.sign(x._array), device=x.device)

0 commit comments

Comments
 (0)