forked from data-apis/array-api-extra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_compat.py
40 lines (38 loc) · 1020 Bytes
/
_compat.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
"""Acquire helpers from array-api-compat."""
# Allow packages that vendor both `array-api-extra` and
# `array-api-compat` to override the import location
try:
from ..._array_api_compat_vendor import ( # pyright: ignore[reportMissingImports]
array_namespace,
device,
is_cupy_namespace,
is_jax_array,
is_jax_namespace,
is_pydata_sparse_namespace,
is_torch_namespace,
is_writeable_array,
size,
)
except ImportError:
from array_api_compat import ( # pyright: ignore[reportMissingTypeStubs]
array_namespace,
device,
is_cupy_namespace,
is_jax_array,
is_jax_namespace,
is_pydata_sparse_namespace,
is_torch_namespace,
is_writeable_array,
size,
)
__all__ = [
"array_namespace",
"device",
"is_cupy_namespace",
"is_jax_array",
"is_jax_namespace",
"is_pydata_sparse_namespace",
"is_torch_namespace",
"is_writeable_array",
"size",
]