Skip to content

Commit 2c5a935

Browse files
Expand docs for .mT attribute
1 parent 67ffb48 commit 2c5a935

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

dpnp/dpnp_array.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,42 @@ def T(self):
110110

111111
@property
112112
def mT(self):
113-
"""View of the matrix transposed array."""
113+
"""
114+
View of the matrix transposed array.
115+
116+
The matrix transpose is the transpose of the last two dimensions, even
117+
if the array is of higher dimension.
118+
119+
Raises
120+
------
121+
ValueError
122+
If the array is of dimension less than 2.
123+
124+
Examples
125+
--------
126+
>>> import dpnp as np
127+
>>> a = np.array([[1, 2], [3, 4]])
128+
>>> a
129+
array([[1, 2],
130+
[3, 4]])
131+
>>> a.mT
132+
array([[1, 3],
133+
[2, 4]])
134+
135+
>>> a = np.arange(8).reshape((2, 2, 2))
136+
>>> a
137+
array([[[0, 1],
138+
[2, 3]],
139+
[[4, 5],
140+
[6, 7]]])
141+
>>> a.mT
142+
array([[[0, 2],
143+
[1, 3]],
144+
[[4, 6],
145+
[5, 7]]])
146+
147+
"""
148+
114149
if self.ndim < 2:
115150
raise ValueError("matrix transpose with ndim < 2 is undefined")
116151

0 commit comments

Comments
 (0)