MCPcopy
hub / github.com/numpy/numpy / rot90

Function rot90

numpy/lib/_function_base_impl.py:180–276  ·  view source on GitHub ↗

Rotate an array by 90 degrees in the plane specified by axes. Rotation direction is from the first towards the second axis. This means for a 2D array with the default `k` and `axes`, the rotation will be counterclockwise. Parameters ---------- m : array_like Ar

(m, k=1, axes=(0, 1))

Source from the content-addressed store, hash-verified

178
179@array_function_dispatch(_rot90_dispatcher)
180def rot90(m, k=1, axes=(0, 1)):
181 """
182 Rotate an array by 90 degrees in the plane specified by axes.
183
184 Rotation direction is from the first towards the second axis.
185 This means for a 2D array with the default `k` and `axes`, the
186 rotation will be counterclockwise.
187
188 Parameters
189 ----------
190 m : array_like
191 Array of two or more dimensions.
192 k : integer
193 Number of times the array is rotated by 90 degrees.
194 axes : (2,) array_like
195 The array is rotated in the plane defined by the axes.
196 Axes must be different.
197
198 Returns
199 -------
200 y : ndarray
201 A rotated view of `m`.
202
203 See Also
204 --------
205 flip : Reverse the order of elements in an array along the given axis.
206 fliplr : Flip an array horizontally.
207 flipud : Flip an array vertically.
208
209 Notes
210 -----
211 ``rot90(m, k=1, axes=(1,0))`` is the reverse of
212 ``rot90(m, k=1, axes=(0,1))``
213
214 ``rot90(m, k=1, axes=(1,0))`` is equivalent to
215 ``rot90(m, k=-1, axes=(0,1))``
216
217 Examples
218 --------
219 >>> import numpy as np
220 >>> m = np.array([[1,2],[3,4]], int)
221 >>> m
222 array([[1, 2],
223 [3, 4]])
224 >>> np.rot90(m)
225 array([[2, 4],
226 [1, 3]])
227 >>> np.rot90(m, 2)
228 array([[4, 3],
229 [2, 1]])
230 >>> m = np.arange(8).reshape((2,2,2))
231 >>> np.rot90(m, 1, (1,2))
232 array([[[1, 3],
233 [0, 2]],
234 [[5, 7],
235 [4, 6]]])
236
237 """

Callers 4

test_basicMethod · 0.90
test_axesMethod · 0.90
test_rotation_axesMethod · 0.90

Calls 4

transposeFunction · 0.90
asanyarrayFunction · 0.85
flipFunction · 0.85
indexMethod · 0.45

Tested by 4

test_basicMethod · 0.72
test_axesMethod · 0.72
test_rotation_axesMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…