File tree Expand file tree Collapse file tree 4 files changed +25
-2
lines changed Expand file tree Collapse file tree 4 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 1
1
"""Static typing support for the array API standard."""
2
2
3
3
__all__ = (
4
+ "Array",
4
5
"HasArrayNamespace",
5
6
"__version__",
6
7
"__version_tuple__",
7
8
)
8
9
9
- from ._array import HasArrayNamespace
10
+ from ._array import Array, HasArrayNamespace
10
11
from ._version import version as __version__, version_tuple as __version_tuple__
Original file line number Diff line number Diff line change 1
- __all__ = ("HasArrayNamespace",)
1
+ __all__ = (
2
+ "Array",
3
+ "HasArrayNamespace",
4
+ )
2
5
3
6
from types import ModuleType
4
7
from typing import Literal, Protocol
@@ -52,3 +55,10 @@ def __array_namespace__(
52
55
53
56
"""
54
57
...
58
+
59
+
60
+ class Array(
61
+ HasArrayNamespace[NamespaceT_co],
62
+ Protocol[NamespaceT_co],
63
+ ):
64
+ """Array API specification for array object attributes and methods."""
Original file line number Diff line number Diff line change @@ -27,3 +27,9 @@ ns: ModuleType = a_ns.__array_namespace__()
27
27
# Incorrect values are caught when using `__array_namespace__` and
28
28
# backpropagated to the type of `a_ns`
29
29
_: xpt.HasArrayNamespace[dict[str, int]] = nparr # not caught
30
+
31
+ # =========================================================
32
+ # `xpt.Array`
33
+
34
+ # Check NamespaceT_co assignment
35
+ a_ns: xpt.Array[ModuleType] = nparr
Original file line number Diff line number Diff line change @@ -34,3 +34,9 @@ ns: ModuleType = a_ns.__array_namespace__()
34
34
# Incorrect values are caught when using `__array_namespace__` and
35
35
# backpropagated to the type of `a_ns`
36
36
_: xpt.HasArrayNamespace[dict[str, int]] = nparr # not caught
37
+
38
+ # =========================================================
39
+ # `xpt.Array`
40
+
41
+ # Check NamespaceT_co assignment
42
+ a_ns: xpt.Array[ModuleType] = nparr
You can’t perform that action at this time.
0 commit comments