@@ -146,6 +146,35 @@ def size(self) -> int | None:
146146 ...
147147
148148
149+ class HasTranspose (Protocol ):
150+ """Protocol for array classes that support the transpose operation."""
151+
152+ def T (self ) -> Self : # noqa: N802
153+ """Transpose of the array.
154+
155+ The array instance must be two-dimensional. If the array instance is not
156+ two-dimensional, an error should be raised.
157+
158+ Returns:
159+ Self: two-dimensional array whose first and last dimensions (axes)
160+ are permuted in reverse order relative to original array. The
161+ returned array must have the same data type as the original
162+ array.
163+
164+ Notes:
165+ Limiting the transpose to two-dimensional arrays (matrices) deviates
166+ from the NumPy et al practice of reversing all axes for arrays
167+ having more than two-dimensions. This is intentional, as reversing
168+ all axes was found to be problematic (e.g., conflicting with the
169+ mathematical definition of a transpose which is limited to matrices;
170+ not operating on batches of matrices; et cetera). In order to
171+ reverse all axes, one is recommended to use the functional
172+ `PermuteDims` interface found in this specification.
173+
174+ """
175+ ...
176+
177+
149178@docstring_setter (** _array_docstrings )
150179class Array (
151180 # ------ Attributes -------
@@ -155,6 +184,7 @@ class Array(
155184 HasNDim ,
156185 HasShape ,
157186 HasSize ,
187+ HasTranspose ,
158188 # ------ Methods -------
159189 HasArrayNamespace [NS_co ],
160190 op .CanPosSelf ,
0 commit comments