Skip to content

Commit 32dd396

Browse files
committed
ENH: allow __array_namespace_info__().default_device() return None
While not in the 2024.12 spec, this is generally agreed on in data-apis/array-api#923
1 parent 3052f8b commit 32dd396

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

array_api_tests/test_inspection_functions.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ def test_devices(self):
3131
assert hasattr(out, "default_device")
3232

3333
assert isinstance(out.devices(), list)
34-
assert out.default_device() in out.devices()
34+
if out.default_device() is not None:
35+
# Per https://github.com/data-apis/array-api/issues/923
36+
# default_device() can return None. Otherwise, it must be a valid device.
37+
assert out.default_device() in out.devices()
3538

3639
def test_default_dtypes(self):
3740
out = xp.__array_namespace_info__()
@@ -40,13 +43,13 @@ def test_default_dtypes(self):
4043
default_dtypes = out.default_dtypes(device=device)
4144
assert isinstance(default_dtypes, dict)
4245
expected_subset = (
43-
{"real floating", "complex floating", "integral"}
44-
& available_kinds()
46+
{"real floating", "complex floating", "integral"}
47+
& available_kinds()
4548
| {"indexing"}
4649
)
4750
assert expected_subset.issubset(set(default_dtypes.keys()))
4851

49-
52+
5053
atomic_kinds = [
5154
"bool",
5255
"signed integer",

0 commit comments

Comments
 (0)