File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed 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+ @runtime_checkable
8+ class HasNamespace (Protocol ):
9+ """Protocol for classes that have an `__array_namespace__` method.
10+
11+ This is a runtime checkable protocol.
12+
13+ Example:
14+
15+ >>> import array_api_typing as apt
16+ >>>
17+ >>> class MyArray:
18+ ... def __array_namespace__(self):
19+ ... return "my namespace"
20+ >>>
21+ >>> x = MyArray()
22+ >>> print(isinstance(x, apt.HasNamespace))
23+ True
24+
25+ """
26+
27+ def __array_namespace__ (self ) -> object :
28+ ...
You can’t perform that action at this time.
0 commit comments