Skip to content

Commit 5ffd635

Browse files
committed
Special cases over note in x.__bool__()
1 parent 8212e67 commit 5ffd635

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

spec/API_specification/array_api/array_object.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,15 @@ def __bool__(self: array, /) -> bool:
226226
"""
227227
Converts a zero-dimensional array to a Python ``bool`` object.
228228
229-
.. note::
230-
If ``self`` has a numeric data type, a value equal to ``0`` must cast to ``False``, and a value not equal to ``0`` must cast to ``True``.
229+
**Special cases**
230+
231+
For real-valued floating-point operands,
232+
233+
- If ``self`` is ``NaN``, the result is ``True``.
234+
- If ``self`` is either ``+infinity`` or ``-infinity``, the result is ``True``.
235+
- If ``self`` is either ``+0`` or ``-0``, the result is ``False``.
236+
237+
For complex floating-point operands, special cases must be handled as if the operation is implemented as ``bool(real(self)) and bool(imag(self))``.
231238
232239
Parameters
233240
----------

0 commit comments

Comments
 (0)