File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 2222
2323# Build docs
2424/src /array_api_typing /_version.py
25+
26+ # Mac files
27+ .DS_Store
Original file line number Diff line number Diff line change 11"""Static typing support for the array API standard."""
22
3- __all__ = ()
3+ __all__ = [ "HasNamespace" ]
44
55from ._version import version as __version__ , version_tuple as __version_tuple__
6+ from ._namespace import HasNamespace
Original file line number Diff line number Diff line change 1+ """Static typing support for the array API standard."""
2+
3+ __all__ = ["HasNamespace" ]
4+
5+ from typing import Protocol , runtime_checkable
6+
7+
8+ @runtime_checkable
9+ class HasNamespace (Protocol ):
10+ """Protocol for classes that have an `__array_namespace__` method.
11+
12+ This is a runtime checkable protocol.
13+
14+ Example:
15+ >>> import array_api_typing as xpt
16+ >>>
17+ >>> class MyArray:
18+ ... def __array_namespace__(self):
19+ ... return "my namespace"
20+ >>>
21+ >>> x = MyArray()
22+ >>> print(isinstance(x, xpt.HasNamespace))
23+ True
24+
25+ """
26+
27+ def __array_namespace__ (self ) -> object : ... # noqa: PLW3201
You can’t perform that action at this time.
0 commit comments