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/API_specification/array_object.md
+25-2Lines changed: 25 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -737,7 +737,7 @@ Evaluates `self_i << other_i` for each element of an array instance with the res
737
737
738
738
```{note}
739
739
740
-
Element-wise results must equal the results returned by the equivalent element-wise function [`less_equal(x1, x2)`](elementwise_functions.md#bitwise_left_shiftx1-x2-).
740
+
Element-wise results must equal the results returned by the equivalent element-wise function [`bitwise_left_shift(x1, x2)`](elementwise_functions.md#bitwise_left_shiftx1-x2-).
741
741
```
742
742
743
743
(method-__lt__)=
@@ -1062,7 +1062,30 @@ Element-wise results must equal the results returned by the equivalent element-w
- value(s) to set. Must be compatible with `self[key]` (see {ref}`broadcasting`).
1080
+
1081
+
```{note}
1082
+
1083
+
Setting array values must not affect the data type of `self`.
1084
+
1085
+
When `value` is a Python scalar (i.e., `int`, `float`, `bool`), behavior must follow specification guidance on mixing arrays with Python scalars (see {ref}`type-promotion`).
1086
+
1087
+
When `value` is an `array` of a different data type than `self`, how values are cast to the data type of `self` is implementation defined.
Copy file name to clipboardExpand all lines: spec/API_specification/data_types.md
+27-13Lines changed: 27 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,6 @@
6
6
7
7
A conforming implementation of the array API standard must provide and support the following data types.
8
8
9
-
A conforming implementation of the array API standard must define a default floating-point data type (either `float32` or `float64`), as well as a default integer data type (`int32` or `int64`). These default data types must be the same across platforms. The default integer data type may vary depending on whether Python is 32-bit or 64-bit.
10
-
11
-
```{note}
12
-
The default floating-point and array index integer data types should be clearly defined in a conforming library's documentation.
13
-
```
14
-
15
-
16
9
## bool
17
10
18
11
Boolean (`True` or `False`).
@@ -60,8 +53,9 @@ IEEE 754 double-precision (64-bit) binary floating-point number (see IEEE 754-20
60
53
61
54
:::{admonition} Future extension
62
55
:class: hint
63
-
It is expected that in the next version of this standard, `complex64` and `complex128`
64
-
dtypes will be added, with these casting rules (will be added to {ref}`type-promotion`):
56
+
`complex64` and `complex128` dtypes are expected to be included in the next
57
+
version of this standard and to have the following casting rules (will be added
58
+
to {ref}`type-promotion`):
65
59
66
60

67
61
@@ -78,13 +72,33 @@ Implementations may provide other ways to specify data types (e.g.,
78
72
A conforming implementation of the array API standard may provide and support additional data types beyond those described in this specification.
79
73
```
80
74
75
+
(data-type-defaults)=
76
+
## Default Data Types
77
+
78
+
A conforming implementation of the array API standard must define a default floating-point data type (either `float32` or `float64`) and a default integer data type (`int32` or `int64`).
79
+
80
+
The default data types must be the same across platforms.
81
+
82
+
The default integer data type may vary depending on whether Python is 32-bit or 64-bit.
83
+
84
+
```{note}
85
+
The default floating-point and integer data types should be clearly defined in a conforming library's documentation.
86
+
```
87
+
81
88
(data-type-categories)=
82
89
## Data Type Categories
83
90
84
-
For the purposes of this specification, the following data type categories are defined.
85
-
Libraries do not need to organize dtypes according to these categories. These
86
-
are only for organizing the functions in this specification itself. Future versions of
87
-
the specification will include additional categories for complex data types.
91
+
For the purpose of organizing functions within this specification, the following data type categories are defined.
92
+
93
+
```{note}
94
+
Conforming libraries are not required to organize dtypes according to these categories. These
95
+
categories are only intended for use within this specification.
96
+
```
97
+
98
+
```{note}
99
+
Future versions of the specification will include additional categories for
Copy file name to clipboardExpand all lines: spec/API_specification/indexing.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -160,6 +160,12 @@ _Rationale: this is consistent with bounds-checking for single-axis indexing. An
160
160
161
161
## Boolean Array Indexing
162
162
163
+
:::{admonition} Data-dependent output shape
164
+
:class: important
165
+
166
+
For common boolean array use cases (e.g., using a dynamically-sized boolean array mask to filter the values of another array), the shape of the output array is data-dependent; hence, array libraries which build computation graphs (e.g., JAX, Dask, etc.) may find boolean array indexing difficult to implement. Accordingly, such libraries may choose to omit boolean array indexing. See {ref}`data-dependent-output-shapes` section for more details.
167
+
:::
168
+
163
169
An array must support indexing where the **sole index** is an `M`-dimensional boolean array `B` with shape `S1 = (s1, ..., sM)` according to the following rules. Let `A` be an `N`-dimensional array with shape `S2 = (s1, ..., sM, ..., sN)`.
164
170
165
171
- If `N >= M`, then `A[B]` must replace the first `M` dimensions of `A` with a single dimension having a size equal to the number of `True` elements in `B`. The values in the resulting array must be in row-major (C-style order); this is equivalent to `A[nonzero(B)]`.
Copy file name to clipboardExpand all lines: spec/API_specification/searching_functions.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,6 +69,12 @@ Returns the indices of the minimum values along a specified axis. When the minim
69
69
(function-nonzero)=
70
70
### nonzero(x, /)
71
71
72
+
:::{admonition} Data-dependent output shape
73
+
:class: important
74
+
75
+
The shape of the output array for this function depends on the data values in the input array; hence, array libraries which build computation graphs (e.g., JAX, Dask, etc.) may find this function difficult to implement without knowing array values. Accordingly, such libraries may choose to omit this function. See {ref}`data-dependent-output-shapes` section for more details.
76
+
:::
77
+
72
78
Returns the indices of the array elements which are non-zero.
The shapes of one or more of output arrays for this function depend on the data values in the input array; hence, array libraries which build computation graphs (e.g., JAX, Dask, etc.) may find this function difficult to implement without knowing array values. Accordingly, such libraries may choose to omit this function. See {ref}`data-dependent-output-shapes` section for more details.
22
+
:::
23
+
18
24
Returns the unique elements of an input array `x`.
19
25
20
26
#### Parameters
@@ -59,6 +65,4 @@ Returns the unique elements of an input array `x`.
59
65
60
66
- **counts**: _<array>_
61
67
62
-
- an array containing the number of times each unique element occurs in `x`.
63
-
64
-
_TODO: should this be `int64`? This probably makes sense for most hardware; however, may be undesirable for older hardware and/or embedded systems._
68
+
- an array containing the number of times each unique element occurs in `x`. The returned array must have the default integer data type.
0 commit comments