File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,25 @@ def shape(self) -> tuple[int | None, ...]:
127
127
...
128
128
129
129
130
+ class HasSize (Protocol ):
131
+ """Protocol for array classes that have a size attribute."""
132
+
133
+ @property
134
+ def size (self ) -> int | None :
135
+ """Number of elements in an array.
136
+
137
+ Returns:
138
+ int | None: number of elements in an array. The returned value must
139
+ be `None` if and only if one or more array dimensions are
140
+ unknown.
141
+
142
+ Notes:
143
+ This must equal the product of the array's dimensions.
144
+
145
+ """
146
+ ...
147
+
148
+
130
149
@docstring_setter (** _array_docstrings )
131
150
class Array (
132
151
# ------ Attributes -------
@@ -135,6 +154,7 @@ class Array(
135
154
HasMatrixTranspose ,
136
155
HasNDim ,
137
156
HasShape ,
157
+ HasSize ,
138
158
# ------ Methods -------
139
159
HasArrayNamespace [NS_co ],
140
160
op .CanPosSelf ,
You can’t perform that action at this time.
0 commit comments