MCPcopy Index your code
hub / github.com/numpy/numpy / flip

Function flip

numpy/lib/_function_base_impl.py:284–371  ·  view source on GitHub ↗

Reverse the order of elements in an array along the given axis. The shape of the array is preserved, but the elements are reordered. Parameters ---------- m : array_like Input array. axis : None or int or tuple of ints, optional Axis or axes along which to

(m, axis=None)

Source from the content-addressed store, hash-verified

282
283@array_function_dispatch(_flip_dispatcher)
284def flip(m, axis=None):
285 """
286 Reverse the order of elements in an array along the given axis.
287
288 The shape of the array is preserved, but the elements are reordered.
289
290 Parameters
291 ----------
292 m : array_like
293 Input array.
294 axis : None or int or tuple of ints, optional
295 Axis or axes along which to flip over. The default,
296 axis=None, will flip over all of the axes of the input array.
297 If axis is negative it counts from the last to the first axis.
298
299 If axis is a tuple of ints, flipping is performed on all of the axes
300 specified in the tuple.
301
302 Returns
303 -------
304 out : array_like
305 A view of `m` with the entries of axis reversed. Since a view is
306 returned, this operation is done in constant time.
307
308 See Also
309 --------
310 flipud : Flip an array vertically (axis=0).
311 fliplr : Flip an array horizontally (axis=1).
312
313 Notes
314 -----
315 flip(m, 0) is equivalent to flipud(m).
316
317 flip(m, 1) is equivalent to fliplr(m).
318
319 flip(m, n) corresponds to ``m[...,::-1,...]`` with ``::-1`` at position n.
320
321 flip(m) corresponds to ``m[::-1,::-1,...,::-1]`` with ``::-1`` at all
322 positions.
323
324 flip(m, (0, 1)) corresponds to ``m[::-1,::-1,...]`` with ``::-1`` at
325 position 0 and position 1.
326
327 Examples
328 --------
329 >>> import numpy as np
330 >>> A = np.arange(8).reshape((2,2,2))
331 >>> A
332 array([[[0, 1],
333 [2, 3]],
334 [[4, 5],
335 [6, 7]]])
336 >>> np.flip(A, 0)
337 array([[[4, 5],
338 [6, 7]],
339 [[0, 1],
340 [2, 3]]])
341 >>> np.flip(A, 1)

Callers 1

rot90Function · 0.85

Calls 1

asarrayFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…