Skip to content

Commit 08a7e46

Browse files
committed
✨ HasNDim
1 parent ba2f76b commit 08a7e46

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
@@ -97,11 +97,26 @@ def mT(self) -> Self: # noqa: N802
9797
...
9898

9999

100+
class HasNDim(Protocol):
101+
"""Protocol for array classes that have a number of dimensions attribute."""
102+
103+
@property
104+
def ndim(self) -> int:
105+
"""Number of array dimensions (axes).
106+
107+
Returns:
108+
int: number of array dimensions (axes).
109+
110+
"""
111+
...
112+
113+
100114
class Array(
101115
# ------ Attributes -------
102116
HasDType[DTypeT_co],
103117
HasDevice,
104118
HasMatrixTranspose,
119+
HasNDim,
105120
# ------- Methods ---------
106121
HasArrayNamespace[NamespaceT_co],
107122
# -------------------------

0 commit comments

Comments
 (0)