Skip to content

Commit d0ec621

Browse files
authored
Merge pull request #32 from data-apis/dtype-clarification
Add notes to dtype sections to make sections easier to understand
2 parents f801759 + 70bbb33 commit d0ec621

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

spec/API_specification/data_types.md

+10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ A conforming implementation of the array API standard must provide and support t
88

99
A conforming implementation of the array API standard may provide and support additional data types beyond those described in this specification.
1010

11+
.. note::
12+
13+
These dtypes are objects that can be used as dtype specifiers in functions and methods (e.g., `zeros((2, 3), dtype=float32)`). A conforming implementation may add methods or attributes to dtype objects; these are not part of this specification however.
14+
15+
.. note::
16+
17+
Implementations may provide others ways to specify dtypes (e.g.,
18+
`zeros((2, 3), dtype='f4')`); these are not part of this specification however.
19+
20+
1121
## bool
1222

1323
Boolean (`True` or `False`) stored as a byte.

spec/API_specification/type_promotion.md

+22-11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ A conforming implementation of the array API standard must implement the followi
88

99
A conforming implementation of the array API standard may support additional type promotion rules beyond those described in this specification.
1010

11+
.. note::
12+
13+
Type codes are used here to keep tables readable, they are not part of the standard.
14+
In code, use the dtype objects specified in :ref:`data-types` (e.g., `int16` rather than `'i2'`).
15+
1116
## Rules
1217

1318
<!-- Note: please keep table columns aligned -->
@@ -23,10 +28,10 @@ A conforming implementation of the array API standard may support additional typ
2328

2429
where
2530

26-
- **i1**: 8-bit signed integer
27-
- **i2**: 16-bit signed integer
28-
- **i4**: 32-bit signed integer
29-
- **i8**: 64-bit signed integer
31+
- **i1**: 8-bit signed integer (i.e., `int8`)
32+
- **i2**: 16-bit signed integer (i.e., `int16`)
33+
- **i4**: 32-bit signed integer (i.e., `int32`)
34+
- **i8**: 64-bit signed integer (i.e., `int64`)
3035

3136
- unsigned integer type promotion table:
3237

@@ -39,10 +44,10 @@ A conforming implementation of the array API standard may support additional typ
3944

4045
where
4146

42-
- **u1**: 8-bit unsigned integer
43-
- **u2**: 16-bit unsigned integer
44-
- **u4**: 32-bit unsigned integer
45-
- **u8**: 64-bit unsigned integer
47+
- **u1**: 8-bit unsigned integer (i.e., `uint8`)
48+
- **u2**: 16-bit unsigned integer (i.e., `uint16`)
49+
- **u4**: 32-bit unsigned integer (i.e., `uint32`)
50+
- **u8**: 64-bit unsigned integer (i.e., `uint64`)
4651

4752
- mixed unsigned and signed integer type promotion table:
4853

@@ -61,10 +66,16 @@ A conforming implementation of the array API standard may support additional typ
6166

6267
where
6368

64-
- **f4**: single-precision (32-bit) floating-point number
65-
- **f8**: double-precision (64-bit) floating-point number
69+
- **f4**: single-precision (32-bit) floating-point number (i.e., `float32`)
70+
- **f8**: double-precision (64-bit) floating-point number (i.e., `float64`)
6671

6772
## Notes
6873

6974
- Type promotion rules **strictly** apply when determining the common result type for two **array** operands during an arithmetic operation, regardless of array dimension. Accordingly, zero-dimensional arrays are subject to the same type promotion rules as dimensional arrays.
70-
- Non-array ("scalar") operands are **not** permitted to participate in type promotion.
75+
- Non-array ("scalar") operands are **not** permitted to participate in type promotion.
76+
77+
78+
.. note::
79+
80+
Mixed integer and floating-point type promotion rules are not specified
81+
because behaviour varies between implementations.

0 commit comments

Comments
 (0)