Skip to content

Commit f26bd49

Browse files
committed
Add signbit
1 parent 730e716 commit f26bd49

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

array_api_strict/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
remainder,
178178
round,
179179
sign,
180+
signbit,
180181
sin,
181182
sinh,
182183
square,
@@ -244,6 +245,7 @@
244245
"remainder",
245246
"round",
246247
"sign",
248+
"signbit",
247249
"sin",
248250
"sinh",
249251
"square",

array_api_strict/_elementwise_functions.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,18 @@ def sign(x: Array, /) -> Array:
791791
return Array._new(np.sign(x._array))
792792

793793

794+
@requires_api_version('2023.12')
795+
def signbit(x: Array, /) -> Array:
796+
"""
797+
Array API compatible wrapper for :py:func:`np.signbit <numpy.signbit>`.
798+
799+
See its docstring for more information.
800+
"""
801+
if x.dtype not in _real_floating_dtypes:
802+
raise TypeError("Only real floating-point dtypes are allowed in signbit")
803+
return Array._new(np.signbit(x._array))
804+
805+
794806
def sin(x: Array, /) -> Array:
795807
"""
796808
Array API compatible wrapper for :py:func:`np.sin <numpy.sin>`.

array_api_strict/tests/test_elementwise_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def nargs(func):
7575
"remainder": "real numeric",
7676
"round": "numeric",
7777
"sign": "numeric",
78+
"signbit": "real floating-point",
7879
"sin": "floating-point",
7980
"sinh": "floating-point",
8081
"sqrt": "floating-point",

0 commit comments

Comments
 (0)