|
25 | 25 | if not IS_WASM: |
26 | 26 | import numexpr |
27 | 27 |
|
28 | | -from .version import __version__ |
| 28 | +from .version import __array_api_version__, __version__ |
29 | 29 |
|
30 | 30 | __version__ = __version__ |
| 31 | +__array_api_version__ = __array_api_version__ |
31 | 32 | """ |
32 | 33 | Python-Blosc2 version. |
33 | 34 | """ |
@@ -226,34 +227,28 @@ def __array_namespace_info__() -> Info: |
226 | 227 | """ |
227 | 228 | Return information about the array namespace following the Array API specification. |
228 | 229 | """ |
| 230 | + |
| 231 | + def _raise(exc): |
| 232 | + raise exc |
| 233 | + |
229 | 234 | return Info( |
230 | | - capabilities={ |
| 235 | + capabilities=lambda: { |
231 | 236 | "boolean indexing": True, |
232 | 237 | "data-dependent shapes": False, |
233 | | - "max dimensions": 8, |
| 238 | + "max dimensions": MAX_DIM, |
234 | 239 | }, |
235 | | - default_device=None, |
236 | | - default_dtypes={ |
| 240 | + default_device=lambda: "cpu", |
| 241 | + default_dtypes=lambda device=None: { |
237 | 242 | "real floating": DEFAULT_FLOAT, |
238 | 243 | "complex floating": DEFAULT_COMPLEX, |
239 | 244 | "integral": DEFAULT_INT, |
240 | 245 | "indexing": DEFAULT_INDEX, |
241 | | - }, |
242 | | - dtypes={ |
243 | | - "bool": bool_, |
244 | | - "int8": int8, |
245 | | - "int16": int16, |
246 | | - "int32": int32, |
247 | | - "int64": int64, |
248 | | - "uint8": uint8, |
249 | | - "uint16": uint16, |
250 | | - "uint32": uint32, |
251 | | - "uint64": uint64, |
252 | | - "float32": float32, |
253 | | - "float64": float64, |
254 | | - "complex64": complex64, |
255 | | - "complex128": complex128, |
256 | | - }, |
| 246 | + } |
| 247 | + if (device == "cpu" or device is None) |
| 248 | + else _raise(ValueError("Only cpu devices allowed")), |
| 249 | + dtypes=lambda device=None, kind=None: np.__array_namespace_info__().dtypes(kind=kind, device=device) |
| 250 | + if (device == "cpu" or device is None) |
| 251 | + else _raise(ValueError("Only cpu devices allowed")), |
257 | 252 | devices=lambda: ["cpu"], |
258 | 253 | name="blosc2", |
259 | 254 | version=__version__, |
|
0 commit comments