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, ...]:
127127 ...
128128
129129
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+
130149@docstring_setter (** _array_docstrings )
131150class Array (
132151 # ------ Attributes -------
@@ -135,6 +154,7 @@ class Array(
135154 HasMatrixTranspose ,
136155 HasNDim ,
137156 HasShape ,
157+ HasSize ,
138158 # ------ Methods -------
139159 HasArrayNamespace [NS_co ],
140160 op .CanPosSelf ,
You can’t perform that action at this time.
0 commit comments