Skip to content

Commit 9971768

Browse files
committed
Special cases over notes for boolean cross-kind casting
1 parent 5ffd635 commit 9971768

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

spec/API_specification/array_api/array_object.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,12 @@ def __complex__(self: array, /) -> complex:
251251
"""
252252
Converts a zero-dimensional array to a Python ``complex`` object.
253253
254-
.. note::
255-
If ``self`` has a boolean data type, a value of ``True`` must cast to ``1+0j``, and a value of ``False`` must cast to ``0+0j``.
254+
**Special cases**
255+
256+
For boolean operands,
257+
258+
- If ``self`` is ``True``, the result is ``1+0j``.
259+
- If ``self`` is ``False``, the result is ``0+0j``.
256260
257261
Parameters
258262
----------
@@ -374,8 +378,12 @@ def __float__(self: array, /) -> float:
374378
.. note::
375379
Casting integer values outside the representable bounds of Python's float type is not specified and is implementation-dependent.
376380
377-
.. note::
378-
If ``self`` has a boolean data type, a value of ``True`` must cast to ``1``, and a value of ``False`` must cast to ``0``.
381+
**Special cases**
382+
383+
For boolean operands,
384+
385+
- If ``self`` is ``True``, the result is ``1``.
386+
- If ``self`` is ``False``, the result is ``0``.
379387
380388
Parameters
381389
----------
@@ -529,11 +537,13 @@ def __int__(self: array, /) -> int:
529537
"""
530538
Converts a zero-dimensional array to a Python ``int`` object.
531539
532-
.. note::
533-
If ``self`` has a boolean data type, a value of ``True`` must cast to ``1``, and a value of ``False`` must cast to ``0``.
534-
535540
**Special cases**
536541
542+
For boolean operands,
543+
544+
- If ``self`` is ``True``, the result is ``1``.
545+
- If ``self`` is ``False``, the result is ``0``.
546+
537547
For floating-point operands,
538548
539549
- If ``self`` is a finite number, the result is the integer part of ``self``.

0 commit comments

Comments
 (0)