4
4
from __future__ import annotations
5
5
6
6
from types import ModuleType
7
+ from typing import Any , TypeGuard
7
8
8
9
# TODO import from typing (requires Python >=3.13)
9
10
from typing_extensions import TypeIs
@@ -12,29 +13,33 @@ from ._typing import Array, Device
12
13
13
14
# pylint: disable=missing-class-docstring,unused-argument
14
15
15
- class Namespace (ModuleType ):
16
- def device (self , x : Array , / ) -> Device : ...
17
-
18
16
def array_namespace (
19
17
* xs : Array | complex | None ,
20
18
api_version : str | None = None ,
21
19
use_compat : bool | None = None ,
22
- ) -> Namespace : ...
20
+ ) -> ModuleType : ...
23
21
def device (x : Array , / ) -> Device : ...
24
22
def is_array_api_obj (x : object , / ) -> TypeIs [Array ]: ...
25
- def is_array_api_strict_namespace (xp : ModuleType , / ) -> TypeIs [ Namespace ] : ...
26
- def is_cupy_namespace (xp : ModuleType , / ) -> TypeIs [ Namespace ] : ...
27
- def is_dask_namespace (xp : ModuleType , / ) -> TypeIs [ Namespace ] : ...
28
- def is_jax_namespace (xp : ModuleType , / ) -> TypeIs [ Namespace ] : ...
29
- def is_numpy_namespace (xp : ModuleType , / ) -> TypeIs [ Namespace ] : ...
30
- def is_pydata_sparse_namespace (xp : ModuleType , / ) -> TypeIs [ Namespace ] : ...
31
- def is_torch_namespace (xp : ModuleType , / ) -> TypeIs [ Namespace ] : ...
32
- def is_cupy_array (x : object , / ) -> TypeIs [Array ]: ...
33
- def is_dask_array (x : object , / ) -> TypeIs [Array ]: ...
34
- def is_jax_array (x : object , / ) -> TypeIs [Array ]: ...
35
- def is_numpy_array (x : object , / ) -> TypeIs [Array ]: ...
36
- def is_pydata_sparse_array (x : object , / ) -> TypeIs [Array ]: ...
37
- def is_torch_array (x : object , / ) -> TypeIs [Array ]: ...
38
- def is_lazy_array (x : object , / ) -> TypeIs [Array ]: ...
39
- def is_writeable_array (x : object , / ) -> TypeIs [Array ]: ...
23
+ def is_array_api_strict_namespace (xp : ModuleType , / ) -> bool : ...
24
+ def is_cupy_namespace (xp : ModuleType , / ) -> bool : ...
25
+ def is_dask_namespace (xp : ModuleType , / ) -> bool : ...
26
+ def is_jax_namespace (xp : ModuleType , / ) -> bool : ...
27
+ def is_numpy_namespace (xp : ModuleType , / ) -> bool : ...
28
+ def is_pydata_sparse_namespace (xp : ModuleType , / ) -> bool : ...
29
+ def is_torch_namespace (xp : ModuleType , / ) -> bool : ...
30
+ def is_cupy_array (x : object , / ) -> TypeGuard [Array ]: ...
31
+ def is_dask_array (x : object , / ) -> TypeGuard [Array ]: ...
32
+ def is_jax_array (x : object , / ) -> TypeGuard [Array ]: ...
33
+ def is_numpy_array (x : object , / ) -> TypeGuard [Array ]: ...
34
+ def is_pydata_sparse_array (x : object , / ) -> TypeGuard [Array ]: ...
35
+ def is_torch_array (x : object , / ) -> TypeGuard [Array ]: ...
36
+ def is_lazy_array (x : object , / ) -> TypeGuard [Array ]: ...
37
+ def is_writeable_array (x : object , / ) -> TypeGuard [Array ]: ...
40
38
def size (x : Array , / ) -> int | None : ...
39
+ def to_device ( # type: ignore[explicit-any]
40
+ x : Array ,
41
+ device : Device , # pylint: disable=redefined-outer-name
42
+ / ,
43
+ * ,
44
+ stream : int | Any | None = None ,
45
+ ) -> Array : ...
0 commit comments