bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / rollaxis
_ArrayFunctionDispatcher
numpy:rollaxis
source: /dev/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/numeric.py :1327
Signature
def rollaxis ( a , axis , start = 0 ) Summary
Roll the specified axis backwards, until it lies in a given position.
Extended Summary
This function continues to be supported for backward compatibility, but you should prefer moveaxis. The moveaxis function was added in NumPy 1.11.
Parameters
a: ndarrayInput array.
axis: intThe axis to be rolled. The positions of the other axes do not change relative to one another.
start: int, optionalWhen
start <= axis, the axis is rolled back until it lies in this position. Whenstart > axis, the axis is rolled until it lies before this position. The default, 0, results in a "complete" roll. The following table describes how negative values ofstartare interpreted:
Returns
res: ndarrayFor NumPy >= 1.10.0 a view of
ais always returned. For earlier NumPy versions a view ofais returned only if the order of the axes is changed, otherwise the input array is returned.
Examples
import numpy as np a = np.ones((3,4,5,6)) np.rollaxis(a, 3, 1).shape np.rollaxis(a, 2).shape np.rollaxis(a, 1, 4).shape✓
See also
- moveaxis
Move array axes to new positions.
- roll
Roll the elements of an array by a number of positions along a given axis.
Aliases
-
numpy.rollaxis