-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathtest_inspection_functions.py
45 lines (33 loc) · 1.13 KB
/
test_inspection_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import pytest
from hypothesis import given, strategies as st
from array_api_tests.dtype_helpers import available_kinds
from . import xp
pytestmark = pytest.mark.min_version("2023.12")
def test_array_namespace_info():
out = xp.__array_namespace_info__()
capabilities = out.capabilities()
assert isinstance(capabilities, dict)
out.default_device()
default_dtypes = out.default_dtypes()
assert isinstance(default_dtypes, dict)
expected_subset = {"real floating", "complex floating", "integral"} & available_kinds() | {"indexing"}
assert expected_subset.issubset(set(default_dtypes.keys()))
devices = out.devices()
assert isinstance(devices, list)
atomic_kinds = [
"bool",
"signed integer",
"unsigned integer",
"real floating",
"complex floating",
]
@given(
st.one_of(
st.none(),
st.sampled_from(atomic_kinds + ["integral", "numeric"]),
st.lists(st.sampled_from(atomic_kinds), unique=True, min_size=1).map(tuple),
)
)
def test_array_namespace_info_dtypes(kind):
out = xp.__array_namespace_info__().dtypes(kind=kind)
assert isinstance(out, dict)