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
* Add complex floating-point data types
* Add complex dtypes to numeric category and add real-valued data types category
* Replace "numeric data type" with "real-valued data type"
This change ensures that the specification maintains the status quo
in terms of accepted dtypes for the current set of APIs.
Subsequent PRs will add support to APIs for complex number data types
on a case-by-case basis.
* Add category for real-valued floating-point data types
* Fix underline
Copy file name to clipboardexpand all lines: spec/API_specification/data_types.rst
+30-14
Original file line number
Diff line number
Diff line change
@@ -62,19 +62,20 @@ float64
62
62
63
63
IEEE 754 double-precision (64-bit) binary floating-point number (see IEEE 754-2019).
64
64
65
-
.. note::
66
-
IEEE 754-2019 requires support for subnormal (a.k.a., denormal) numbers, which are useful for supporting gradual underflow. However, hardware support for subnormal numbers is not universal, and many platforms (e.g., accelerators) and compilers support toggling denormals-are-zero (DAZ) and/or flush-to-zero (FTZ) behavior to increase performance and to guard against timing attacks.
65
+
complex64
66
+
---------
67
67
68
-
Accordingly, subnormal behavior is left unspecified and, thus, implementation-defined. Conforming implementations may vary in their support for subnormal numbers.
68
+
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).
69
69
70
-
.. admonition:: Future extension
71
-
:class: admonition tip
70
+
complex128
71
+
----------
72
72
73
-
``complex64`` and ``complex128`` data types are expected to be included in the next version of this standard and to have the following casting rules (will be added to :ref:`type-promotion`):
73
+
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).
IEEE 754-2019 requires support for subnormal (a.k.a., denormal) numbers, which are useful for supporting gradual underflow. However, hardware support for subnormal numbers is not universal, and many platforms (e.g., accelerators) and compilers support toggling denormals-are-zero (DAZ) and/or flush-to-zero (FTZ) behavior to increase performance and to guard against timing attacks.
76
77
77
-
See `array-api/issues/102 <https://github.com/data-apis/array-api/issues/102>`_ for more details
78
+
Accordingly, subnormal behavior is left unspecified and, thus, implementation-defined. Conforming implementations may vary in their support for subnormal numbers.
78
79
79
80
.. note::
80
81
A conforming implementation of the array API standard may provide and support additional data types beyond those described in this specification.
@@ -116,11 +117,14 @@ Default Data Types
116
117
117
118
A conforming implementation of the array API standard must define the following default data types.
118
119
119
-
- a default floating-point data type (either ``float32`` or ``float64``).
120
+
- a default real-valued floating-point data type (either ``float32`` or ``float64``).
121
+
- a default complex floating-point data type (either ``complex64`` or ``complex128``).
120
122
- a default integer data type (either ``int32`` or ``int64``).
121
123
- a default array index data type (either ``int32`` or ``int64``).
122
124
123
-
The default floating-point data type must be the same across platforms.
125
+
The default real-valued floating-point and complex floating-point data types must be the same across platforms.
126
+
127
+
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``.
124
128
125
129
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.
126
130
@@ -139,14 +143,16 @@ For the purpose of organizing functions within this specification, the following
139
143
.. note::
140
144
Conforming libraries are not required to organize data types according to these categories. These categories are only intended for use within this specification.
141
145
142
-
.. note::
143
-
Future versions of the specification will include additional categories for complex data types.
144
-
145
146
146
147
Numeric Data Types
147
148
~~~~~~~~~~~~~~~~~~
148
149
149
-
``int8``, ``int16``, ``int32``, ``int64``, ``uint8``, ``uint16``, ``uint32``, ``uint64``, ``float32``, and ``float64`` (i.e., all data types except for ``bool``).
array instance. Should have a numeric data type. Must have at least one dimension. If ``self`` is one-dimensional having shape ``(M,)`` and ``other`` has more than one dimension, ``self`` must be promoted to a two-dimensional array by prepending ``1`` to its dimensions (i.e., must have shape ``(1, M)``). After matrix multiplication, the prepended dimensions in the returned array must be removed. If ``self`` has more than one dimension (including after vector-to-matrix promotion), ``shape(self)[:-2]`` must be compatible with ``shape(other)[:-2]`` (after vector-to-matrix promotion) (see :ref:`broadcasting`). If ``self`` has shape ``(..., M, K)``, the innermost two dimensions form matrices on which to perform matrix multiplication.
601
+
array instance. Should have a real-valued data type. Must have at least one dimension. If ``self`` is one-dimensional having shape ``(M,)`` and ``other`` has more than one dimension, ``self`` must be promoted to a two-dimensional array by prepending ``1`` to its dimensions (i.e., must have shape ``(1, M)``). After matrix multiplication, the prepended dimensions in the returned array must be removed. If ``self`` has more than one dimension (including after vector-to-matrix promotion), ``shape(self)[:-2]`` must be compatible with ``shape(other)[:-2]`` (after vector-to-matrix promotion) (see :ref:`broadcasting`). If ``self`` has shape ``(..., M, K)``, the innermost two dimensions form matrices on which to perform matrix multiplication.
602
602
other: array
603
-
other array. Should have a numeric data type. Must have at least one dimension. If ``other`` is one-dimensional having shape ``(N,)`` and ``self`` has more than one dimension, ``other`` must be promoted to a two-dimensional array by appending ``1`` to its dimensions (i.e., must have shape ``(N, 1)``). After matrix multiplication, the appended dimensions in the returned array must be removed. If ``other`` has more than one dimension (including after vector-to-matrix promotion), ``shape(other)[:-2]`` must be compatible with ``shape(self)[:-2]`` (after vector-to-matrix promotion) (see :ref:`broadcasting`). If ``other`` has shape ``(..., K, N)``, the innermost two dimensions form matrices on which to perform matrix multiplication.
603
+
other array. Should have a real-valued data type. Must have at least one dimension. If ``other`` is one-dimensional having shape ``(N,)`` and ``self`` has more than one dimension, ``other`` must be promoted to a two-dimensional array by appending ``1`` to its dimensions (i.e., must have shape ``(N, 1)``). After matrix multiplication, the appended dimensions in the returned array must be removed. If ``other`` has more than one dimension (including after vector-to-matrix promotion), ``shape(other)[:-2]`` must be compatible with ``shape(self)[:-2]`` (after vector-to-matrix promotion) (see :ref:`broadcasting`). If ``other`` has shape ``(..., K, N)``, the innermost two dimensions form matrices on which to perform matrix multiplication.
array instance. Should have a real-valued data type.
669
669
other: Union[int, float, array]
670
-
other array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a numeric data type.
670
+
other array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a real-valued data type.
671
671
672
672
Returns
673
673
-------
674
674
out: array
675
-
an array containing the element-wise results. Each element-wise result must have the same sign as the respective element ``other_i``. The returned array must have a floating-point data type determined by :ref:`type-promotion`.
675
+
an array containing the element-wise results. Each element-wise result must have the same sign as the respective element ``other_i``. The returned array must have a real-valued floating-point data type determined by :ref:`type-promotion`.
If both ``self`` and ``other`` have integer data types, the result of ``__pow__`` when `other_i` is negative (i.e., less than zero) is unspecified and thus implementation-dependent.
810
810
811
-
If ``self`` has an integer data type and ``other`` has a floating-point data type, behavior is implementation-dependent, as type promotion between data type "kinds" (e.g., integer versus floating-point) is unspecified.
811
+
If ``self`` has an integer data type and ``other`` has a real-valued floating-point data type, behavior is implementation-dependent, as type promotion between data type "kinds" (e.g., integer versus floating-point) is unspecified.
array instance whose elements correspond to the exponentiation base. Should have a numeric data type.
845
+
array instance whose elements correspond to the exponentiation base. Should have a real-valued data type.
846
846
other: Union[int, float, array]
847
-
other array whose elements correspond to the exponentiation exponent. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a numeric data type.
847
+
other array whose elements correspond to the exponentiation exponent. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a real-valued data type.
If one or both of ``self`` and ``other`` have integer data types, the result is implementation-dependent, as type promotion between data type "kinds" (e.g., integer versus floating-point) is unspecified.
930
930
931
-
Specification-compliant libraries may choose to raise an error or return an array containing the element-wise results. If an array is returned, the array must have a floating-point data type.
931
+
Specification-compliant libraries may choose to raise an error or return an array containing the element-wise results. If an array is returned, the array must have a real-valued floating-point data type.
array instance. Should have a real-valued data type.
964
964
other: Union[int, float, array]
965
-
other array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a numeric data type.
965
+
other array. Must be compatible with ``self`` (see :ref:`broadcasting`). Should have a real-valued data type.
966
966
967
967
Returns
968
968
-------
969
969
out: array
970
-
an array containing the element-wise results. The returned array should have a floating-point data type determined by :ref:`type-promotion`.
970
+
an array containing the element-wise results. The returned array should have a real-valued floating-point data type determined by :ref:`type-promotion`.
0 commit comments