You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: spec/draft/API_specification/type_promotion.rst
+18-6
Original file line number
Diff line number
Diff line change
@@ -110,7 +110,6 @@ where
110
110
- **c16**: double-precision complex floating-point number (i.e., ``complex128``)
111
111
composed of two double-precision (64-bit) floating-point numbers
112
112
113
-
114
113
Notes
115
114
~~~~~
116
115
@@ -140,12 +139,25 @@ where ``<op>`` is a built-in operator (including in-place operators, but excludi
140
139
141
140
Provided the above requirements are met, the expected behavior is equivalent to:
142
141
143
-
1. Convert the scalar to zero-dimensional array with the same data type as that of the array used in the expression.
142
+
1. Convert the scalar to a zero-dimensional array with the same data type as that of the array used in the expression.
144
143
2. Execute the operation for ``array <op> 0-D array`` (or ``0-D array <op> array`` if ``scalar`` was the left-hand argument).
145
144
146
-
.. note::
147
-
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.
145
+
Additionally, using Python ``complex`` scalars together with arrays must be supported for:
146
+
147
+
- ``array <op> scalar``
148
+
- ``scalar <op> array``
149
+
150
+
where ``<op>`` is a built-in operator (including in-place operators, but excluding the matmul ``@`` operator; see :ref:`operators` for operators supported by the array object) and ``scalar`` has a type and value compatible with a promoted array data type:
151
+
152
+
- a Python ``complex`` for real-valued floating-point array data types.
153
+
154
+
Provided the above requirements are met, the expected behavior is equivalent to:
155
+
156
+
1. Convert the scalar to a zero-dimensional array with a complex floating-point array data type having the same precision as that of the array operand used in the expression (e.g., if an array has a ``float32`` data type, the scalar must be converted to a zero-dimensional array having a ``complex64`` data type; if an array has a ``float64`` data type, the scalar must be converted to a zero-dimensional array have a ``complex128`` data type).
157
+
2. Execute the operation for ``array <op> 0-D array`` (or ``0-D array <op> array`` if ``scalar`` was the left-hand argument).
158
+
159
+
Behavior is 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.
148
160
149
-
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.
161
+
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.
150
162
151
-
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.
163
+
Behavior is not specified when mixing a Python ``complex`` and an array with an integer data type; this may give ``complex64``, ``complex128``, or raise an exception. Behavior is implementation-specific.
0 commit comments