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
Returns a dictionary of array library capabilities.
56
56
57
-
The dictionary must contain the following keys:
58
-
59
-
- `"boolean indexing"`: boolean indicating whether an array library supports boolean indexing. If a conforming implementation fully supports boolean indexing in compliance with this specification (see :ref:`indexing`), the corresponding dictionary value must be ``True``; otherwise, the value must be ``False``.
60
-
- `"data-dependent shapes"`: boolean indicating whether an array library supports data-dependent output shapes. If a conforming implementation fully supports all APIs included in this specification (excluding boolean indexing) which have data-dependent output shapes, as explicitly demarcated throughout the specification, the corresponding dictionary value must be ``True``; otherwise, the value must be ``False``.
61
-
- `"max dimensions"`: maximum number of supported dimensions. If a conforming implementation supports arrays having an arbitrary number of dimensions (potentially infinite), the corresponding dictionary value must be ``None``; otherwise, the value must be a finite integer.
62
-
63
57
Returns
64
58
-------
65
59
out: Capabilities
66
-
a dictionary of array library capabilities.
60
+
a dictionary of array library capabilities. The returned dictionary **must** contain the following keys:
61
+
62
+
- `"boolean indexing"`: boolean indicating whether an array library supports boolean indexing. If a conforming implementation fully supports boolean indexing in compliance with this specification (see :ref:`indexing`), the corresponding dictionary value **must** be ``True``; otherwise, the value **must** be ``False``.
63
+
- `"data-dependent shapes"`: boolean indicating whether an array library supports data-dependent output shapes. If a conforming implementation fully supports all APIs included in this specification (excluding boolean indexing) which have data-dependent output shapes, as explicitly demarcated throughout the specification, the corresponding dictionary value **must** be ``True``; otherwise, the value **must** be ``False``.
64
+
- `"max dimensions"`: maximum number of supported dimensions. If a conforming implementation supports arrays having an arbitrary number of dimensions (potentially infinite), the corresponding dictionary value **must** be ``None``; otherwise, the value **must** be a finite integer.
67
65
68
66
Notes
69
67
-----
@@ -98,31 +96,28 @@ def default_dtypes(
98
96
"""
99
97
Returns a dictionary containing default data types.
100
98
101
-
The dictionary must have the following keys:
102
-
103
-
- `"real floating"`: default real floating-point data type.
104
-
- `"complex floating"`: default complex floating-point data type.
105
-
- `"integral"`: default integral data type.
106
-
- `"indexing"`: default array index data type.
107
-
108
-
Dictionary values must be the corresponding data type object.
109
-
110
99
Parameters
111
100
----------
112
101
device: Optional[device]
113
-
device for which to return default data types. If ``device`` is ``None``, the returned data types must be the default data types for the current device; otherwise, the returned data types must be default data types specific to the specified device. Default: ``None``.
114
-
115
-
.. note::
116
-
Some array libraries have the concept of a device context manager, allowing library consumers to manage the current device context. When ``device`` is ``None``, libraries supporting a device context should return the default data types for the current device. For libraries without a context manager or supporting only a single device, those libraries should return the default data types for the default device.
102
+
device for which to return default data types. If ``device`` is ``None``, the returned data types **must** be the default data types for the current device; otherwise, the returned data types **must** be default data types specific to the specified device. Default: ``None``.
117
103
118
104
Returns
119
105
-------
120
106
out: DefaultDataTypes
121
-
a dictionary containing the default data type for respective data type kinds.
107
+
a dictionary containing the default data type for respective data type kinds. The returned dictionary **must** have the following keys:
108
+
109
+
- `"real floating"`: default real floating-point data type.
110
+
- `"complex floating"`: default complex floating-point data type.
111
+
- `"integral"`: default integral data type.
112
+
- `"indexing"`: default array index data type.
113
+
114
+
Dictionary values **must** be the corresponding data type object.
122
115
123
116
Notes
124
117
-----
125
118
119
+
- Some array libraries have the concept of a device context manager, allowing library consumers to manage the current device context. When ``device`` is ``None``, libraries supporting a device context **must** return the default data types for the current device. For libraries without a context manager or supporting only a single device, those libraries **must** return the default data types for the default device.
120
+
126
121
.. versionadded: 2023.12
127
122
"""
128
123
@@ -135,20 +130,14 @@ def dtypes(
135
130
"""
136
131
Returns a dictionary of supported *Array API* data types.
137
132
138
-
.. note::
139
-
While specification-conforming array libraries may support additional data types which are not present in this specification, data types which are not present in this specification should not be included in the returned dictionary.
140
-
141
-
.. note::
142
-
Specification-conforming array libraries must only return supported data types having expected properties as described in :ref:`data-types`. For example, if a library decides to alias ``float32`` as ``float64``, that library must not include ``float64`` in the dictionary of supported data types.
143
-
144
133
Parameters
145
134
----------
146
135
kind: Optional[Union[str, Tuple[str, ...]]]
147
136
data type kind.
148
137
149
-
- If ``kind`` is ``None``, the function must return a dictionary containing all supported Array API data types.
138
+
- If ``kind`` is ``None``, the function **must** return a dictionary containing all supported Array API data types.
150
139
151
-
- If ``kind`` is a string, the function must return a dictionary containing the data types belonging to the specified data type kind. The following data type kinds must be supported:
140
+
- If ``kind`` is a string, the function **must** return a dictionary containing the data types belonging to the specified data type kind. The following data type kinds **must** be supported:
152
141
153
142
- ``'bool'``: boolean data types (e.g., ``bool``).
154
143
- ``'signed integer'``: signed integer data types (e.g., ``int8``, ``int16``, ``int32``, ``int64``).
@@ -158,26 +147,27 @@ def dtypes(
158
147
- ``'complex floating'``: complex floating-point data types (e.g., ``complex64``, ``complex128``).
159
148
- ``'numeric'``: numeric data types. Shorthand for ``('integral', 'real floating', 'complex floating')``.
160
149
161
-
- If ``kind`` is a tuple, the tuple specifies a union of data type kinds, and the function must return a dictionary containing the data types belonging to at least one of the specified data type kinds.
150
+
- If ``kind`` is a tuple, the tuple specifies a union of data type kinds, and the function **must** return a dictionary containing the data types belonging to at least one of the specified data type kinds.
162
151
163
152
Default: ``None``.
164
-
device: Optional[device]
165
-
device for which to return supported data types. If ``device`` is ``None``, the returned data types must be the supported data types for the current device; otherwise, the returned data types must be supported data types specific to the specified device. Default: ``None``.
166
153
167
-
.. note::
168
-
Some array libraries have the concept of a device context manager, allowing library consumers to manage the current device context. When ``device`` is ``None``, libraries supporting a device context should return the supported data types for the current device. For libraries without a context manager or supporting only a single device, those libraries should return the supported data types for the default device.
154
+
device: Optional[device]
155
+
device for which to return supported data types. If ``device`` is ``None``, the returned data types **must** be the supported data types for the current device; otherwise, the returned data types **must** be supported data types specific to the specified device. Default: ``None``.
169
156
170
157
Returns
171
158
-------
172
159
out: DataTypes
173
-
a dictionary containing supported data types.
174
-
175
-
.. note::
176
-
Dictionary keys must only consist of canonical names as defined in :ref:`data-types`.
160
+
a dictionary containing supported data types. The returned dictionary **must** only contain keys corresponding to the canonical names as defined in :ref:`data-types`.
177
161
178
162
Notes
179
163
-----
180
164
165
+
- While specification-conforming array libraries **may** support additional data types which are not present in this specification, data types which are not present in this specification **must not** be included in the returned dictionary.
166
+
167
+
- Specification-conforming array libraries **must** only return supported data types having expected properties as described in :ref:`data-types`. For example, if a library decides to alias ``float32`` as ``float64``, that library **must not** include ``float64`` in the dictionary of supported data types.
168
+
169
+
- Some array libraries have the concept of a device context manager, allowing library consumers to manage the current device context. When ``device`` is ``None``, libraries supporting a device context **must** return the supported data types for the current device. For libraries without a context manager or supporting only a single device, those libraries **must** return the supported data types for the default device.
Each device object (see :ref:`device-support`) in the list of returned devices must be an object which can be provided as a valid keyword-argument to array creation functions.
187
+
- Each device object (see :ref:`device-support`) in the list of returned devices **must** be an object which can be provided as a valid keyword-argument to array creation functions.
0 commit comments