@@ -151,6 +151,35 @@ def size(self) -> int | None:
151
151
...
152
152
153
153
154
+ class HasTranspose (Protocol ):
155
+ """Protocol for array classes that support the transpose operation."""
156
+
157
+ def T (self ) -> Self : # noqa: N802
158
+ """Transpose of the array.
159
+
160
+ The array instance must be two-dimensional. If the array instance is not
161
+ two-dimensional, an error should be raised.
162
+
163
+ Returns:
164
+ Self: two-dimensional array whose first and last dimensions (axes)
165
+ are permuted in reverse order relative to original array. The
166
+ returned array must have the same data type as the original
167
+ array.
168
+
169
+ Notes:
170
+ Limiting the transpose to two-dimensional arrays (matrices) deviates
171
+ from the NumPy et al practice of reversing all axes for arrays
172
+ having more than two-dimensions. This is intentional, as reversing
173
+ all axes was found to be problematic (e.g., conflicting with the
174
+ mathematical definition of a transpose which is limited to matrices;
175
+ not operating on batches of matrices; et cetera). In order to
176
+ reverse all axes, one is recommended to use the functional
177
+ `PermuteDims` interface found in this specification.
178
+
179
+ """
180
+ ...
181
+
182
+
154
183
class Array (
155
184
# ------ Attributes -------
156
185
HasDType [DTypeT_co ],
@@ -159,6 +188,7 @@ class Array(
159
188
HasNDim ,
160
189
HasShape ,
161
190
HasSize ,
191
+ HasTranspose ,
162
192
# ------- Methods ---------
163
193
HasArrayNamespace [NamespaceT_co ],
164
194
# -------------------------
0 commit comments