1- __all__ = ("HasArrayNamespace" ,)
1+ __all__ = (
2+ "Array" ,
3+ "HasArrayNamespace" ,
4+ )
25
36from types import ModuleType
47from typing import Literal , Protocol
@@ -12,7 +15,7 @@ class HasArrayNamespace(Protocol[NamespaceT_co]):
1215
1316 This `Protocol` is intended for use in static typing to ensure that an
1417 object has an `__array_namespace__` method that returns a namespace for
15- array operations. This `Protocol` should not be used at runtime, for type
18+ array operations. This `Protocol` should not be used at runtime for type
1619 checking or as a base class.
1720
1821 Example:
@@ -52,3 +55,26 @@ def __array_namespace__(
5255
5356 """
5457 ...
58+
59+
60+ class Array (
61+ HasArrayNamespace [NamespaceT_co ],
62+ # -------------------------
63+ Protocol [NamespaceT_co ],
64+ ):
65+ """Array API specification for array object attributes and methods.
66+
67+ The type is: ``Array[+NamespaceT = ModuleType] = Array[NamespaceT]`` where:
68+
69+ - `NamespaceT` is the type of the array namespace. It defaults to
70+ `ModuleType`, which is the most common form of array namespace (e.g.,
71+ `numpy`, `cupy`, etc.). However, it can be any type, e.g. a
72+ `types.SimpleNamespace`, to allow for wrapper libraries to
73+ semi-dynamically define their own array namespaces based on the wrapped
74+ array type.
75+
76+ This type is intended for use in static typing to ensure that an object has
77+ the attributes and methods defined in the array API specification. It should
78+ not be used at runtime for type checking or as a base class.
79+
80+ """
0 commit comments