Skip to content

Commit 41719af

Browse files
committed
Factor out the list of wrapped libraries in the tests
This does remove jax testing from the isdtype test, since we should not test jax functionality for non-helper functions.
1 parent e75ba03 commit 41719af

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

tests/_helpers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import pytest
66

77

8+
wrapped_libraries = ["numpy", "cupy", "torch", "dask.array"]
9+
all_libraries = wrapped_libraries + "jax.numpy"
10+
811
def import_(library, wrapper=False):
912
if 'jax' in library and sys.version_info < (3, 9):
1013
pytest.skip('JAX array API support does not support Python 3.8')

tests/test_all.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
import sys
1414

15-
from ._helpers import import_
15+
from ._helpers import import_, wrapped_libraries
1616

1717
import pytest
1818

19-
@pytest.mark.parametrize("library", ["common", "cupy", "numpy", "torch", "dask.array"])
19+
@pytest.mark.parametrize("library", ["common"] + wrapped_libraries)
2020
def test_all(library):
2121
import_(library, wrapper=True)
2222

tests/test_array_namespace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import array_api_compat
1010
from array_api_compat import array_namespace
1111

12-
from ._helpers import import_
12+
from ._helpers import import_, all_libraries
1313

14-
@pytest.mark.parametrize("library", ["cupy", "numpy", "torch", "dask.array", "jax.numpy"])
14+
@pytest.mark.parametrize("library", all_libraries)
1515
@pytest.mark.parametrize("api_version", [None, "2021.12"])
1616
def test_array_namespace(library, api_version):
1717
xp = import_(library)

tests/test_common.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from array_api_compat import is_array_api_obj, device, to_device
55

6-
from ._helpers import import_
6+
from ._helpers import import_, wrapped_libraries, all_libraries
77

88
import pytest
99
import numpy as np
@@ -29,7 +29,7 @@ def test_is_xp_array(library, func):
2929

3030
assert is_array_api_obj(x)
3131

32-
@pytest.mark.parametrize("library", ["cupy", "numpy", "torch", "dask.array", "jax.numpy"])
32+
@pytest.mark.parametrize("library", all_libraries)
3333
def test_device(library):
3434
xp = import_(library, wrapper=True)
3535

@@ -43,7 +43,7 @@ def test_device(library):
4343
assert device(x) == device(x2)
4444

4545

46-
@pytest.mark.parametrize("library", ["cupy", "numpy", "torch", "dask.array"])
46+
@pytest.mark.parametrize("library", wrapped_libraries)
4747
def test_to_device_host(library):
4848
# different libraries have different semantics
4949
# for DtoH transfers; ensure that we support a portable

tests/test_isdtype.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import pytest
77

8-
from ._helpers import import_
8+
from ._helpers import import_, wrapped_libraries
99

1010
# Check the known dtypes by their string names
1111

@@ -64,7 +64,7 @@ def isdtype_(dtype_, kind):
6464
assert type(res) is bool # noqa: E721
6565
return res
6666

67-
@pytest.mark.parametrize("library", ["cupy", "numpy", "torch", "dask.array", "jax.numpy"])
67+
@pytest.mark.parametrize("library", wrapped_libraries)
6868
def test_isdtype_spec_dtypes(library):
6969
xp = import_(library, wrapper=True)
7070

@@ -98,7 +98,7 @@ def test_isdtype_spec_dtypes(library):
9898
'bfloat16',
9999
]
100100

101-
@pytest.mark.parametrize("library", ["cupy", "numpy", "torch", "dask.array", "jax.numpy"])
101+
@pytest.mark.parametrize("library", wrapped_libraries)
102102
@pytest.mark.parametrize("dtype_", additional_dtypes)
103103
def test_isdtype_additional_dtypes(library, dtype_):
104104
xp = import_(library, wrapper=True)

0 commit comments

Comments
 (0)