Skip to content

Commit 4245bc1

Browse files
authored
Merge pull request #350 from steff456/data_types-rst
PR: Transform data_types.md to rst
2 parents ee857f8 + d374b4c commit 4245bc1

File tree

3 files changed

+184
-165
lines changed

3 files changed

+184
-165
lines changed

spec/API_specification/data_types.md

Lines changed: 0 additions & 165 deletions
This file was deleted.

spec/API_specification/data_types.rst

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
.. _data-types:
2+
3+
Data Types
4+
==========
5+
6+
Array API specification for supported data types.
7+
8+
A conforming implementation of the array API standard must provide and support the following data types.
9+
10+
bool
11+
----
12+
13+
Boolean (``True`` or ``False``).
14+
15+
int8
16+
----
17+
18+
An 8-bit signed integer whose values exist on the interval ``[-128, +127]``.
19+
20+
int16
21+
-----
22+
23+
A 16-bit signed integer whose values exist on the interval ``[−32,767, +32,767]``.
24+
25+
int32
26+
-----
27+
28+
A 32-bit signed integer whose values exist on the interval ``[−2,147,483,647, +2,147,483,647]``.
29+
30+
int64
31+
-----
32+
33+
A 64-bit signed integer whose values exist on the interval ``[−9,223,372,036,854,775,807, +9,223,372,036,854,775,807]``.
34+
35+
uint8
36+
-----
37+
38+
An 8-bit unsigned integer whose values exist on the interval ``[0, +255]``.
39+
40+
uint16
41+
------
42+
43+
A 16-bit unsigned integer whose values exist on the interval ``[0, +65,535]``.
44+
45+
uint32
46+
------
47+
48+
A 32-bit unsigned integer whose values exist on the interval ``[0, +4,294,967,295]``.
49+
50+
uint64
51+
------
52+
53+
A 64-bit unsigned integer whose values exist on the interval ``[0, +18,446,744,073,709,551,615]``.
54+
55+
float32
56+
-------
57+
58+
IEEE 754 single-precision (32-bit) binary floating-point number (see IEEE 754-2019).
59+
60+
float64
61+
-------
62+
63+
IEEE 754 double-precision (64-bit) binary floating-point number (see IEEE 754-2019).
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.
67+
68+
Accordingly, subnormal behavior is left unspecified and, thus, implementation-defined. Conforming implementations may vary in their support for subnormal numbers.
69+
70+
.. admonition:: Future extension
71+
:class: admonition tip
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`):
74+
75+
.. image:: /_static/images/dtype_promotion_complex.png
76+
77+
See `array-api/issues/102 <https://github.com/data-apis/array-api/issues/102>`_ for more details
78+
79+
.. note::
80+
A conforming implementation of the array API standard may provide and support additional data types beyond those described in this specification.
81+
82+
.. _data-type-objects:
83+
84+
Data Type Objects
85+
-----------------
86+
87+
Data types ("dtypes") are objects which are used as ``dtype`` specifiers in functions and methods (e.g., ``zeros((2, 3), dtype=float32)``).
88+
89+
.. note::
90+
A conforming implementation may add additional methods or attributes to data type objects beyond those described in this specification.
91+
92+
.. note::
93+
Implementations may provide other ways to specify data types (e.g., ``zeros((2, 3), dtype='f4')``) which are not described in this specification; however, in order to ensure portability, array library consumers are recommended to use data type objects as provided by specification conforming array libraries.
94+
95+
A conforming implementation of the array API standard must provide and support data type objects having the following attributes and methods.
96+
97+
Methods
98+
~~~~~~~
99+
100+
..
101+
NOTE: please keep the functions in alphabetical order
102+
103+
.. currentmodule:: signatures.data_types
104+
105+
.. autosummary::
106+
:toctree: generated
107+
:template: method.rst
108+
109+
__eq__
110+
111+
112+
.. _data-type-defaults:
113+
114+
Default Data Types
115+
------------------
116+
117+
A conforming implementation of the array API standard must define the following default data types.
118+
119+
- a default floating-point data type (either ``float32`` or ``float64``).
120+
- a default integer data type (either ``int32`` or ``int64``).
121+
- a default array index data type (either ``int32`` or ``int64``).
122+
123+
The default floating-point data type must be the same across platforms.
124+
125+
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+
127+
The default array index data type may be ``int32`` on 32-bit platforms, but the default should be ``int64`` otherwise.
128+
129+
.. note::
130+
The default data types should be clearly defined in a conforming library's documentation.
131+
132+
.. _data-type-categories:
133+
134+
Data Type Categories
135+
--------------------
136+
137+
For the purpose of organizing functions within this specification, the following data type categories are defined.
138+
139+
.. note::
140+
Conforming libraries are not required to organize data types according to these categories. These categories are only intended for use within this specification.
141+
142+
.. note::
143+
Future versions of the specification will include additional categories for complex data types.
144+
145+
146+
Numeric Data Types
147+
~~~~~~~~~~~~~~~~~~
148+
149+
``int8``, ``int16``, ``int32``, ``int64``, ``uint8``, ``uint16``, ``uint32``, ``uint64``, ``float32``, and ``float64`` (i.e., all data types except for ``bool``).
150+
151+
Integer Data Types
152+
~~~~~~~~~~~~~~~~~~
153+
154+
``int8``, ``int16``, ``int32``, ``int64``, ``uint8``, ``uint16``, ``uint32``, and ``uint64``.
155+
156+
Floating-point Data Types
157+
~~~~~~~~~~~~~~~~~~~~~~~~~
158+
159+
``float32`` and ``float64``.
160+
161+
Boolean Data Types
162+
~~~~~~~~~~~~~~~~~~
163+
164+
``bool``.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from ._types import dtype
2+
3+
def __eq__(self: dtype, other: dtype, /) -> bool:
4+
"""
5+
Computes the truth value of ``self == other`` in order to test for data type object equality.
6+
7+
Parameters
8+
----------
9+
self: dtype
10+
data type instance. May be any supported data type.
11+
other: dtype
12+
other data type instance. May be any supported data type.
13+
14+
Returns
15+
-------
16+
out: bool
17+
a boolean indicating whether the data type objects are equal.
18+
"""
19+
20+
all = [__eq__]

0 commit comments

Comments
 (0)