Skip to content

Commit 6e0c630

Browse files
authored
Add complex number support to isnan (#532)
1 parent 857e6ad commit 6e0c630

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

spec/API_specification/array_api/elementwise_functions.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -1058,15 +1058,27 @@ def isnan(x: array, /) -> array:
10581058
"""
10591059
Tests each element ``x_i`` of the input array ``x`` to determine whether the element is ``NaN``.
10601060
1061+
**Special Cases**
1062+
1063+
For real-valued floating-point operands,
1064+
1065+
- If ``x_i`` is ``NaN``, the result is ``True``.
1066+
- In the remaining cases, the result is ``False``.
1067+
1068+
For complex floating-point operands, let ``a = real(x_i)``, ``b = imag(x_i)``, and
1069+
1070+
- If ``a`` or ``b`` is ``NaN``, the result is ``True``.
1071+
- In the remaining cases, the result is ``False``.
1072+
10611073
Parameters
10621074
----------
10631075
x: array
1064-
input array. Should have a real-valued data type.
1076+
input array. Should have a numeric data type.
10651077
10661078
Returns
10671079
-------
10681080
out: array
1069-
an array containing test results. An element ``out_i`` is ``True`` if ``x_i`` is ``NaN`` and ``False`` otherwise. The returned array should have a data type of ``bool``.
1081+
an array containing test results. The returned array should have a data type of ``bool``.
10701082
"""
10711083

10721084
def less(x1: array, x2: array, /) -> array:

0 commit comments

Comments
 (0)