MCPcopy Create free account
hub / github.com/dask/dask / rot90

Function rot90

dask/array/routines.py:242–269  ·  view source on GitHub ↗
(m, k=1, axes=(0, 1))

Source from the content-addressed store, hash-verified

240
241@derived_from(np)
242def rot90(m, k=1, axes=(0, 1)):
243 axes = tuple(axes)
244 if len(axes) != 2:
245 raise ValueError("len(axes) must be 2.")
246
247 m = asanyarray(m)
248
249 if axes[0] == axes[1] or np.absolute(axes[0] - axes[1]) == m.ndim:
250 raise ValueError("Axes must be different.")
251
252 if axes[0] >= m.ndim or axes[0] < -m.ndim or axes[1] >= m.ndim or axes[1] < -m.ndim:
253 raise ValueError(f"Axes={axes} out of range for array of ndim={m.ndim}.")
254
255 k %= 4
256
257 if k == 0:
258 return m[:]
259 if k == 2:
260 return flip(flip(m, axes[0]), axes[1])
261
262 axes_list = list(range(0, m.ndim))
263 axes_list[axes[0]], axes_list[axes[1]] = (axes_list[axes[1]], axes_list[axes[0]])
264
265 if k == 1:
266 return transpose(flip(m, axes[1]), axes_list)
267 else:
268 # k == 3
269 return flip(transpose(m, axes_list), axes[1])
270
271
272def _tensordot(a, b, axes, is_sparse):

Callers

nothing calls this directly

Calls 3

asanyarrayFunction · 0.90
flipFunction · 0.85
transposeFunction · 0.85

Tested by

no test coverage detected