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
@@ -19,17 +18,12 @@ A conforming implementation of the array API standard must implement the followi
19
18
A conforming implementation of the array API standard may support additional type promotion rules beyond those described in this specification.
20
19
21
20
```{note}
22
-
23
-
Type codes are used here to keep tables readable; they are not part of the standard.
24
-
In code, use the data type objects specified in {ref}`data-types` (e.g., `int16` rather than `'i2'`).
21
+
Type codes are used here to keep tables readable; they are not part of the standard. In code, use the data type objects specified in {ref}`data-types` (e.g., `int16` rather than `'i2'`).
25
22
```
26
23
27
24
<!-- Note: please keep table columns aligned -->
28
25
29
-
The following type promotion tables specify the casting behavior for
30
-
operations involving two array operands. When more than two array operands
31
-
participate, application of the promotion tables is associative (i.e., the
32
-
result does not depend on operand order).
26
+
The following type promotion tables specify the casting behavior for operations involving two array operands. When more than two array operands participate, application of the promotion tables is associative (i.e., the result does not depend on operand order).
33
27
34
28
### Signed integer type promotion table
35
29
@@ -90,39 +84,29 @@ where
90
84
- Type promotion of non-numerical data types to numerical data types is unspecified (e.g., `bool` to `intxx` or `floatxx`).
91
85
92
86
```{note}
93
-
94
-
Mixed integer and floating-point type promotion rules are not specified
95
-
because behavior varies between implementations.
87
+
Mixed integer and floating-point type promotion rules are not specified because behavior varies between implementations.
96
88
```
97
89
98
90
### Mixing arrays with Python scalars
99
91
100
-
Using Python scalars (i.e., instances of `bool`, `int`, `float`) together with
101
-
arrays must be supported for:
92
+
Using Python scalars (i.e., instances of `bool`, `int`, `float`) together with arrays must be supported for:
102
93
103
-
-`array <op> scalar`
104
-
-`scalar <op> array`
94
+
-`array <op> scalar`
95
+
-`scalar <op> array`
105
96
106
-
where `<op>` is a built-in operator, including in-place operators (see
107
-
{ref}`operators` for operators supported by the array object) and `scalar` has
108
-
a compatible type and value to the array dtype:
109
-
- Python `bool` for a `bool` array dtype,
110
-
- a Python `int` within the [bounds](data-types) of the given dtype for integer array dtypes,
111
-
- a Python `int` or `float` for floating-point array dtypes
97
+
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 the array data type:
112
98
113
-
The expected behavior is then equivalent to:
99
+
- a Python `bool` for a `bool` array data type.
100
+
- a Python `int` within the [bounds](data-types) of the given data type for integer array data types.
101
+
- a Python `int` or `float` for floating-point array data types.
114
102
115
-
1. Convert the scalar to a 0-D array with the same dtype as that of the array
116
-
used in the expression.
117
-
2. Execute the operation for `array <op> 0-D array` (or `0-D array <op>
118
-
array` if `scalar` was the left-hand argument).
103
+
Provided the above requirements are met, the expected behavior is equivalent to:
119
104
120
-
```{note}
105
+
1. Convert the scalar to zero-dimensional array with the same data type as that of the array used in the expression.
106
+
2. Execute the operation for `array <op> 0-D array` (or `0-D array <op> array` if `scalar` was the left-hand argument).
121
107
122
-
Behaviour is not specified when mixing a Python `float` and an array with an
123
-
integer dtype; this may give `float32`, `float64`, or raise an exception -
124
-
behavior of implementations will differ.
108
+
```{note}
109
+
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.
125
110
126
-
The behavior is also not specified for integers outside of the bounds of a
127
-
given integer dtype. It may overflow, or result in an error.
111
+
The 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.
0 commit comments