Skip to content

Commit f81cc32

Browse files
authored
Add complex number support to isinf (#530)
1 parent 6e0c630 commit f81cc32

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Diff for: spec/API_specification/array_api/elementwise_functions.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -1043,15 +1043,28 @@ def isinf(x: array, /) -> array:
10431043
"""
10441044
Tests each element ``x_i`` of the input array ``x`` to determine if equal to positive or negative infinity.
10451045
1046+
**Special Cases**
1047+
1048+
For real-valued floating-point operands,
1049+
1050+
- If ``x_i`` is either ``+infinity`` or ``-infinity``, the result is ``True``.
1051+
- In the remaining cases, the result is ``False``.
1052+
1053+
For complex floating-point operands, let ``a = real(x_i)``, ``b = imag(x_i)``, and
1054+
1055+
- If ``a`` is either ``+infinity`` or ``-infinity`` and ``b`` is any value (including ``NaN``), the result is ``True``.
1056+
- If ``a`` is either a finite number or ``NaN`` and ``b`` is either ``+infinity`` or ``-infinity``, the result is ``True``.
1057+
- In the remaining cases, the result is ``False``.
1058+
10461059
Parameters
10471060
----------
10481061
x: array
1049-
input array. Should have a real-valued data type.
1062+
input array. Should have a numeric data type.
10501063
10511064
Returns
10521065
-------
10531066
out: array
1054-
an array containing test results. An element ``out_i`` is ``True`` if ``x_i`` is either positive or negative infinity and ``False`` otherwise. The returned array must have a data type of ``bool``.
1067+
an array containing test results. The returned array must have a data type of ``bool``.
10551068
"""
10561069

10571070
def isnan(x: array, /) -> array:

0 commit comments

Comments
 (0)