@@ -18,6 +18,11 @@ In code, use the data type objects specified in {ref}`data-types` (e.g., `int16`
18
18
19
19
<!-- Note: please keep table columns aligned -->
20
20
21
+ The following type promotion tables specify the casting behaviour for
22
+ operations involving two arrays. In situations where more than two arrays
23
+ participate, the table can be used repeatedy on pairs of input arrays (the
24
+ result does not depend on the order in which the arrays are given).
25
+
21
26
### Signed integer type promotion table
22
27
23
28
| | i1 | i2 | i4 | i8 |
82
87
Mixed integer and floating-point type promotion rules are not specified
83
88
because behavior varies between implementations.
84
89
```
90
+
91
+ ### Mixing arrays with Python scalars
92
+
93
+ Using Python scalars (i.e. instances of ` bool ` , ` int ` , ` float ` ) together with arrays must be supported for:
94
+
95
+ - ` array <op> scalar ` ,
96
+ - ` scalar <op> array ` ,
97
+
98
+ where ` <op> ` is a built-in operator (see {ref}` operators ` for operators
99
+ supported by the array object), and ` scalar ` is of the same kind as the array
100
+ dtype (e.g. a ` float ` scalar if the array's dtype is ` float32 ` or ` float64 ` ).
101
+ The expected behaviour is then equivalent to:
102
+
103
+ 1 . Convert the scalar to a 0-D array with the same dtype as that of the array
104
+ used in the expression.
105
+ 2 . Execute the operation for ` array <op> 0-D array ` (or `0-D array <op >
106
+ array` if ` scalar` was the left-hand argument).
107
+
108
+ ``` {note}
109
+
110
+ Note again that mixed integer and floating-point behaviour is not specified.
111
+ Mixing an integer array with a Python float may give `float32`, `float64`,
112
+ or raise an exception - behaviour of implementations will differ.
113
+ ```
0 commit comments