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

Function moveaxis

dask/array/numpy_compat.py:151–166  ·  view source on GitHub ↗
(a, source, destination)

Source from the content-addressed store, hash-verified

149# https://github.com/numpy/numpy/blob/d9b1e32cb8ef90d6b4a47853241db2a28146a57d/numpy/core/numeric.py#L1336-L1405
150@derived_from(np)
151def moveaxis(a, source, destination):
152 source = normalize_axis_tuple(source, a.ndim, "source")
153 destination = normalize_axis_tuple(destination, a.ndim, "destination")
154 if len(source) != len(destination):
155 raise ValueError(
156 "`source` and `destination` arguments must have "
157 "the same number of elements"
158 )
159
160 order = [n for n in range(a.ndim) if n not in source]
161
162 for dest, src in sorted(zip(destination, source)):
163 order.insert(dest, src)
164
165 result = a.transpose(order)
166 return result
167
168
169# Implementation adapted directly from numpy:

Callers

nothing calls this directly

Calls 1

transposeMethod · 0.45

Tested by

no test coverage detected