File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -106,13 +106,35 @@ def ndim(self) -> int:
106
106
...
107
107
108
108
109
+ class HasShape (Protocol ):
110
+ """Protocol for array classes that have a shape attribute."""
111
+
112
+ @property
113
+ def shape (self ) -> tuple [int | None , ...]:
114
+ """Shape of the array.
115
+
116
+ Returns:
117
+ tuple[int | None, ...]: array dimensions. An array dimension must be None
118
+ if and only if a dimension is unknown.
119
+
120
+ Notes:
121
+ For array libraries having graph-based computational models, array
122
+ dimensions may be unknown due to data-dependent operations (e.g.,
123
+ boolean indexing; `A[:, B > 0]`) and thus cannot be statically
124
+ resolved without knowing array contents.
125
+
126
+ """
127
+ ...
128
+
129
+
109
130
@docstring_setter (** _array_docstrings )
110
131
class Array (
111
132
# ------ Attributes -------
112
133
HasDType [DType_co ],
113
134
HasDevice ,
114
135
HasMatrixTranspose ,
115
136
HasNDim ,
137
+ HasShape ,
116
138
# ------ Methods -------
117
139
HasArrayNamespace [NS_co ],
118
140
op .CanPosSelf ,
You can’t perform that action at this time.
0 commit comments