Skip to content

Commit 70fcdd7

Browse files
authored
Require that data type objects implement __eq__ in order to test for data type equality (#273)
* Specify `__eq__` * Fix reference
1 parent 0c99ea2 commit 70fcdd7

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

spec/API_specification/data_types.md

+39-4
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,49 @@ for more details.
6464
:::
6565

6666
```{note}
67-
Data types ("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 data type objects; however, these methods and attributes are not included in this specification.
67+
A conforming implementation of the array API standard may provide and support additional data types beyond those described in this specification.
68+
```
6869

69-
Implementations may provide other ways to specify data types (e.g.,
70-
`zeros((2, 3), dtype='f4')`); however, these are not included in this specification.
70+
(data-type-objects)=
71+
## Data Type Objects
7172

72-
A conforming implementation of the array API standard may provide and support additional data types beyond those described in this specification.
73+
Data types ("dtypes") are objects which are used as `dtype` specifiers in functions and methods (e.g., `zeros((2, 3), dtype=float32)`).
74+
75+
```{note}
76+
A conforming implementation may add additional methods or attributes to data type objects beyond those described in this specification.
7377
```
7478

79+
```{note}
80+
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.
81+
```
82+
83+
A conforming implementation of the array API standard must provide and support data type objects having the following attributes and methods.
84+
85+
### Methods
86+
87+
<!-- NOTE: please keep the methods in alphabetical order -->
88+
89+
(data-type-method-__eq__)=
90+
### \_\_eq\_\_(self, other, /)
91+
92+
Computes the truth value of `self == other` in order to test for data type object equality.
93+
94+
#### Parameters
95+
96+
- **self**: _&lt;dtype&gt;_
97+
98+
- data type instance. May be any supported data type.
99+
100+
- **other**: _&lt;dtype&gt;_
101+
102+
- other data type instance. May be any supported data type.
103+
104+
#### Returns
105+
106+
- **out**: _&lt;bool&gt;_
107+
108+
- a boolean indicating whether the data type objects are equal.
109+
75110
(data-type-defaults)=
76111
## Default Data Types
77112

0 commit comments

Comments
 (0)