File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -97,11 +97,26 @@ def mT(self) -> Self: # noqa: N802
97
97
...
98
98
99
99
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
+
100
114
class Array (
101
115
# ------ Attributes -------
102
116
HasDType [DTypeT_co ],
103
117
HasDevice ,
104
118
HasMatrixTranspose ,
119
+ HasNDim ,
105
120
# ------- Methods ---------
106
121
HasArrayNamespace [NamespaceT_co ],
107
122
# -------------------------
Original file line number Diff line number Diff line change @@ -63,3 +63,7 @@ _: object = x_i32.device
63
63
# Check Attribute `.mT`
64
64
_ : xpt .Array [dtype [Any ]] = x_f32 .mT
65
65
_ : xpt .Array [dtype [Any ]] = x_i32 .mT
66
+
67
+ # Check Attribute `.ndim`
68
+ _ : int = x_f32 .ndim
69
+ _ : int = x_i32 .ndim
Original file line number Diff line number Diff line change @@ -71,3 +71,8 @@ _: object = x_b.device
71
71
_ : xpt .Array [np .dtype [F32 ]] = x_f32 .mT
72
72
_ : xpt .Array [np .dtype [I32 ]] = x_i32 .mT
73
73
_ : xpt .Array [np .dtype [B ]] = x_b .mT
74
+
75
+ # Check Attribute `.ndim`
76
+ _ : int = x_f32 .ndim
77
+ _ : int = x_i32 .ndim
78
+ _ : int = x_b .ndim
You can’t perform that action at this time.
0 commit comments