44from __future__ import annotations
55
66from types import ModuleType
7+ from typing import Any , TypeGuard
78
89# TODO import from typing (requires Python >=3.13)
910from typing_extensions import TypeIs
@@ -12,29 +13,33 @@ from ._typing import Array, Device
1213
1314# pylint: disable=missing-class-docstring,unused-argument
1415
15- class Namespace (ModuleType ):
16- def device (self , x : Array , / ) -> Device : ...
17-
1816def array_namespace (
1917 * xs : Array | complex | None ,
2018 api_version : str | None = None ,
2119 use_compat : bool | None = None ,
22- ) -> Namespace : ...
20+ ) -> ModuleType : ...
2321def device (x : Array , / ) -> Device : ...
2422def 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 ]: ...
4038def 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