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

Function flip

dask/array/routines.py:197–228  ·  view source on GitHub ↗

Reverse element order along axis. Parameters ---------- m : array_like Input array. axis : None or int or tuple of ints, optional Axis or axes to reverse element order of. None will reverse all axes. Returns ------- dask.array.Array The flip

(m, axis=None)

Source from the content-addressed store, hash-verified

195
196
197def flip(m, axis=None):
198 """
199 Reverse element order along axis.
200
201 Parameters
202 ----------
203 m : array_like
204 Input array.
205 axis : None or int or tuple of ints, optional
206 Axis or axes to reverse element order of. None will reverse all axes.
207
208 Returns
209 -------
210 dask.array.Array
211 The flipped array.
212 """
213
214 m = asanyarray(m)
215
216 sl = m.ndim * [slice(None)]
217 if axis is None:
218 axis = range(m.ndim)
219 if not isinstance(axis, Iterable):
220 axis = (axis,)
221 try:
222 for ax in axis:
223 sl[ax] = slice(None, None, -1)
224 except IndexError as e:
225 raise ValueError(f"`axis` of {axis} invalid for {m.ndim}-D array") from e
226 sl = tuple(sl)
227
228 return m[sl]
229
230
231@derived_from(np)

Callers 3

flipudFunction · 0.85
fliplrFunction · 0.85
rot90Function · 0.85

Calls 1

asanyarrayFunction · 0.90

Tested by

no test coverage detected