Skip to content

Commit 859664a

Browse files
committed
✨ HasNDim
1 parent 9ed041b commit 859664a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/array_api_typing/_array.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,27 @@ def mT(self) -> Self: # noqa: N802
9292
...
9393

9494

95+
class HasNDim(Protocol):
96+
"""Protocol for array classes that have a number of dimensions attribute."""
97+
98+
@property
99+
def ndim(self) -> int:
100+
"""Number of array dimensions (axes).
101+
102+
Returns:
103+
int: number of array dimensions (axes).
104+
105+
"""
106+
...
107+
108+
95109
@docstring_setter(**_array_docstrings)
96110
class Array(
97111
# ------ Attributes -------
98112
HasDType[DType_co],
99113
HasDevice,
100114
HasMatrixTranspose,
115+
HasNDim,
101116
# ------ Methods -------
102117
HasArrayNamespace[NS_co],
103118
op.CanPosSelf,

0 commit comments

Comments
 (0)