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 @@ -111,6 +111,25 @@ def shape(self) -> tuple[int | None, ...]:
111
111
...
112
112
113
113
114
+ class HasSize (Protocol ):
115
+ """Protocol for array classes that have a size attribute."""
116
+
117
+ @property
118
+ def size (self ) -> int | None :
119
+ """Number of elements in an array.
120
+
121
+ Returns:
122
+ int | None: number of elements in an array. The returned value must
123
+ be `None` if and only if one or more array dimensions are
124
+ unknown.
125
+
126
+ Notes:
127
+ This must equal the product of the array's dimensions.
128
+
129
+ """
130
+ ...
131
+
132
+
114
133
# ============================================================================
115
134
116
135
@@ -563,6 +582,7 @@ class Array(
563
582
HasMatrixTranspose ,
564
583
HasNDim ,
565
584
HasShape ,
585
+ HasSize ,
566
586
# ------ Methods -------
567
587
HasArrayNamespace [NS_co ],
568
588
CanArrayPos ,
You can’t perform that action at this time.
0 commit comments