Skip to content

Commit f87f609

Browse files
committed
doc: define complex scalar <op> fp array
1 parent 6d205d7 commit f87f609

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

spec/draft/API_specification/type_promotion.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ where ``<op>`` is a built-in operator (including in-place operators, but excludi
132132

133133
- a Python ``bool`` for a ``bool`` array data type.
134134
- a Python ``int`` within the bounds of the given data type for integer array :ref:`data-types`.
135-
- a Python ``int`` or ``float`` for real-valued floating-point array data types.
135+
- a Python ``int``, ``float``, or ``complex`` for real-valued floating-point array data types.
136136
- a Python ``int``, ``float``, or ``complex`` for complex floating-point array data types.
137137

138138
Provided the above requirements are met, the expected behavior is equivalent to:
@@ -143,6 +143,10 @@ Provided the above requirements are met, the expected behavior is equivalent to:
143143
.. note::
144144
Behavior is not specified when mixing a Python ``float`` and an array with an integer data type; this may give ``float32``, ``float64``, or raise an exception. Behavior is implementation-specific.
145145

146-
Similarly, behavior is not specified when mixing a Python ``complex`` and an array with a real-valued data type; this may give ``complex64``, ``complex128``, or raise an exception. Behavior is implementation-specific.
147-
148146
Behavior is also not specified for integers outside of the bounds of a given integer data type. Integers outside of bounds may result in overflow or an error.
147+
148+
149+
.. note::
150+
Mixing a Python ``complex`` and an array with a real-valued data type is allowed; the result is an array of the data type of the same *precision* as the array operand. In other word, ``1j <op> float32_array`` results in a ``complex64`` array; ``1j <op> float64_array`` results in a ``complex128`` array.
151+
152+
Behavior is not specificed when mixing ``complex`` scalars with integer arrays; this may give ``complex64``, ``complex128``, or raise an exception. Behavior is implementation-specific.

0 commit comments

Comments
 (0)