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/array_object.rst
+19-19
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,12 @@ Array object
5
5
6
6
Array API specification for array object attributes and methods.
7
7
8
-
A conforming implementation of the array API standard must provide and support an array object having the following attributes and methods.
8
+
A conforming implementation of the array API standard *must* provide and support an array object having the following attributes and methods.
9
9
10
-
Furthermore, a conforming implementation of the array API standard must support, at minimum, array objects of rank (i.e., number of dimensions) ``0``, ``1``, ``2``, ``3``, and ``4`` and must explicitly document their maximum supported rank ``N``.
10
+
Furthermore, a conforming implementation of the array API standard *must* support, at minimum, array objects of rank (i.e., number of dimensions) ``0``, ``1``, ``2``, ``3``, and ``4`` and *must* explicitly document their maximum supported rank ``N``.
11
11
12
12
.. note::
13
-
Conforming implementations must support zero-dimensional arrays.
13
+
Conforming implementations *must* support zero-dimensional arrays.
14
14
15
15
Apart from array object attributes, such as ``ndim``, ``device``, and ``dtype``, all operations in this standard return arrays (or tuples of arrays), including those operations, such as ``mean``, ``var``, and ``std``, from which some common array libraries (e.g., NumPy) return scalar values.
16
16
@@ -23,12 +23,12 @@ Furthermore, a conforming implementation of the array API standard must support,
23
23
Operators
24
24
---------
25
25
26
-
A conforming implementation of the array API standard must provide and support an array object supporting the following Python operators.
26
+
A conforming implementation of the array API standard *must* provide and support an array object supporting the following Python operators.
27
27
28
28
Arithmetic Operators
29
29
~~~~~~~~~~~~~~~~~~~~
30
30
31
-
A conforming implementation of the array API standard must provide and support an array object supporting the following Python arithmetic operators.
31
+
A conforming implementation of the array API standard *must* provide and support an array object supporting the following Python arithmetic operators.
32
32
33
33
- ``+x``: :meth:`.array.__pos__`
34
34
@@ -75,24 +75,24 @@ A conforming implementation of the array API standard must provide and support a
:meth:`.array.__lt__`, :meth:`.array.__le__`, :meth:`.array.__gt__`, :meth:`.array.__ge__` are only defined for arrays having real-valued data types. Other comparison operators should be defined for arrays having any data type.
166
+
:meth:`.array.__lt__`, :meth:`.array.__le__`, :meth:`.array.__gt__`, :meth:`.array.__ge__` are only defined for arrays having real-valued data types. Other comparison operators *should* be defined for arrays having any data type.
167
167
For backward compatibility, conforming implementations may support complex numbers; however, inequality comparison of complex numbers is unspecified and thus implementation-dependent (see :ref:`complex-number-ordering`).
168
168
169
169
In-place Operators
170
170
~~~~~~~~~~~~~~~~~~
171
171
172
-
A conforming implementation of the array API standard must provide and support an array object supporting the following in-place Python operators.
172
+
A conforming implementation of the array API standard *must* provide and support an array object supporting the following in-place Python operators.
173
173
174
-
An in-place operation must not change the data type or shape of the in-place array as a result of :ref:`type-promotion` or :ref:`broadcasting`.
174
+
An in-place operation *must not* change the data type or shape of the in-place array as a result of :ref:`type-promotion` or :ref:`broadcasting`.
175
175
176
-
An in-place operation must have the same behavior (including special cases) as its respective binary (i.e., two operand, non-assignment) operation. For example, after in-place addition ``x1 += x2``, the modified array ``x1`` must always equal the result of the equivalent binary arithmetic operation ``x1 = x1 + x2``.
176
+
An in-place operation *must* have the same behavior (including special cases) as its respective binary (i.e., two operand, non-assignment) operation. For example, after in-place addition ``x1 += x2``, the modified array ``x1`` *must* always equal the result of the equivalent binary arithmetic operation ``x1 = x1 + x2``.
177
177
178
178
.. note::
179
-
In-place operators must be supported as discussed in :ref:`copyview-mutability`.
179
+
In-place operators *must* be supported as discussed in :ref:`copyview-mutability`.
180
180
181
181
Arithmetic Operators
182
182
""""""""""""""""""""
@@ -206,12 +206,12 @@ Bitwise Operators
206
206
Reflected Operators
207
207
~~~~~~~~~~~~~~~~~~~
208
208
209
-
A conforming implementation of the array API standard must provide and support an array object supporting the following reflected operators.
209
+
A conforming implementation of the array API standard *must* provide and support an array object supporting the following reflected operators.
210
210
211
-
The results of applying reflected operators must match their non-reflected equivalents.
211
+
The results of applying reflected operators *must* match their non-reflected equivalents.
212
212
213
213
.. note::
214
-
All operators for which ``array <op> scalar`` is implemented must have an equivalent reflected operator implementation.
214
+
All operators for which ``array <op> scalar`` is implemented *must* have an equivalent reflected operator implementation.
Copy file name to clipboardExpand all lines: spec/draft/API_specification/broadcasting.rst
+2-2
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ Given an element-wise operation involving two compatible arrays, an array having
19
19
20
20
If two arrays are of unequal rank, the array having a lower rank is promoted to a higher rank by (virtually) prepending singleton dimensions until the number of dimensions matches that of the array having a higher rank.
21
21
22
-
The results of the element-wise operation must be stored in an array having a shape determined by the following algorithm.
22
+
The results of the element-wise operation *must* be stored in an array having a shape determined by the following algorithm.
23
23
24
24
#. Let ``A`` and ``B`` both be arrays.
25
25
@@ -112,7 +112,7 @@ The following examples demonstrate array shapes which do **not** broadcast.
112
112
In-place Semantics
113
113
------------------
114
114
115
-
As implied by the broadcasting algorithm, in-place element-wise operations (including ``__setitem__``) must not change the shape of the in-place array as a result of broadcasting. Such operations should only be supported in the case where the right-hand operand can broadcast to the shape of the left-hand operand, after any indexing operations are performed.
115
+
As implied by the broadcasting algorithm, in-place element-wise operations (including ``__setitem__``) *must not* change the shape of the in-place array as a result of broadcasting. Such operations should only be supported in the case where the right-hand operand can broadcast to the shape of the left-hand operand, after any indexing operations are performed.
| complex64 | Single-precision (64-bit) complex floating-point number whose real and imaginary components must be IEEE 754 single-precision (32-bit) binary floating-point numbers (see IEEE 754-2019). |
37
+
| complex64 | Single-precision (64-bit) complex floating-point number whose real and imaginary components *must* be IEEE 754 single-precision (32-bit) binary floating-point numbers (see IEEE 754-2019). |
| complex128 | Double-precision (128-bit) complex floating-point number whose real and imaginary components must be IEEE 754 double-precision (64-bit) binary floating-point numbers (see IEEE 754-2019). |
39
+
| complex128 | Double-precision (128-bit) complex floating-point number whose real and imaginary components *must* be IEEE 754 double-precision (64-bit) binary floating-point numbers (see IEEE 754-2019). |
Data type objects must have the following methods (no attributes are required):
42
+
Data type objects *must* have the following methods (no attributes are required):
43
43
44
44
..
45
45
NOTE: please keep the functions in alphabetical order
@@ -89,28 +89,28 @@ See :ref:`type-promotion` for specification guidance describing the rules govern
89
89
Default Data Types
90
90
------------------
91
91
92
-
A conforming implementation of the array API standard must define the following default data types.
92
+
A conforming implementation of the array API standard *must* define the following default data types.
93
93
94
94
- a default real-valued floating-point data type (either ``float32`` or ``float64``).
95
95
- a default complex floating-point data type (either ``complex64`` or ``complex128``).
96
96
- a default integer data type (either ``int32`` or ``int64``).
97
97
- a default array index data type (either ``int32`` or ``int64``).
98
98
99
-
The default real-valued floating-point and complex floating-point data types must be the same across platforms.
99
+
The default real-valued floating-point and complex floating-point data types *must* be the same across platforms.
100
100
101
-
The default complex floating-point point data type should match the default real-valued floating-point data type. For example, if the default real-valued floating-point data type is ``float32``, the default complex floating-point data type must be ``complex64``. If the default real-valued floating-point data type is ``float64``, the default complex floating-point data type must be ``complex128``.
101
+
The default complex floating-point point data type *should* match the default real-valued floating-point data type. For example, if the default real-valued floating-point data type is ``float32``, the default complex floating-point data type *must* be ``complex64``. If the default real-valued floating-point data type is ``float64``, the default complex floating-point data type *must* be ``complex128``.
102
102
103
-
The default integer data type should be the same across platforms, but the default may vary depending on whether Python is 32-bit or 64-bit.
103
+
The default integer data type *should* be the same across platforms, but the default may vary depending on whether Python is 32-bit or 64-bit.
104
104
105
-
The default array index data type may be ``int32`` on 32-bit platforms, but the default should be ``int64`` otherwise.
105
+
The default array index data type may be ``int32`` on 32-bit platforms, but the default *should* be ``int64`` otherwise.
106
106
107
107
Note that it is possible that a library supports multiple devices, with not all
108
108
those device types supporting the same data types. In this case, the default
109
109
integer or floating-point data types may vary with device. If that is the case,
110
-
the library should clearly warn about this in its documentation.
110
+
the library *should* clearly warn about this in its documentation.
111
111
112
112
.. note::
113
-
The default data types should be clearly defined in a conforming library's documentation.
113
+
The default data types *should* be clearly defined in a conforming library's documentation.
Copy file name to clipboardExpand all lines: spec/draft/API_specification/index.rst
+8-8
Original file line number
Diff line number
Diff line change
@@ -3,16 +3,16 @@
3
3
API specification
4
4
=================
5
5
6
-
A conforming implementation of the array API standard must provide and support the APIs and behavior detailed in this specification while adhering to the following conventions.
6
+
A conforming implementation of the array API standard *must* provide and support the APIs and behavior detailed in this specification while adhering to the following conventions.
7
7
8
-
- When a function signature includes a `/`, positional parameters must be `positional-only <https://www.python.org/dev/peps/pep-0570/>`_ parameters. See :ref:`function-and-method-signatures`.
9
-
- When a function signature includes a `*`, optional parameters must be `keyword-only <https://www.python.org/dev/peps/pep-3102/>`_ arguments. See :ref:`function-and-method-signatures`.
10
-
- Broadcasting semantics must follow the semantics defined in :ref:`broadcasting`.
11
-
- Unless stated otherwise, functions must support the data types defined in :ref:`data-types`.
8
+
- When a function signature includes a `/`, positional parameters *must* be `positional-only <https://www.python.org/dev/peps/pep-0570/>`_ parameters. See :ref:`function-and-method-signatures`.
9
+
- When a function signature includes a `*`, optional parameters *must* be `keyword-only <https://www.python.org/dev/peps/pep-3102/>`_ arguments. See :ref:`function-and-method-signatures`.
10
+
- Broadcasting semantics *must* follow the semantics defined in :ref:`broadcasting`.
11
+
- Unless stated otherwise, functions *must* support the data types defined in :ref:`data-types`.
12
12
- Functions may only be required for a subset of input data types. Libraries may choose to implement functions for additional data types, but that behavior is not required by the specification. See :ref:`data-type-categories`.
13
-
- Unless stated otherwise, functions must adhere to the type promotion rules defined in :ref:`type-promotion`.
14
-
- Unless stated otherwise, floating-point operations must adhere to IEEE 754-2019.
15
-
- Unless stated otherwise, element-wise mathematical functions must satisfy the minimum accuracy requirements defined in :ref:`accuracy`.
13
+
- Unless stated otherwise, functions *must* adhere to the type promotion rules defined in :ref:`type-promotion`.
0 commit comments