You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
numpy.roll = roll(a, shift, axis=None)
Roll array elements along a given axis.
Elements that roll beyond the last position are re-introduced at
the first.
Parameters
----------
a : array_like
Input array.
shift : int or tuple of ints
The number of places by which elements are shifted. If a tuple,
then `axis` must be a tuple of the same size, and each of the
given axes is shifted by the corresponding number. If an int
while `axis` is a tuple of ints, then the same value is used for
all given axes.
axis : int or tuple of ints, optional
Axis or axes along which elements are shifted. By default, the
array is flattened before shifting, after which the original
shape is restored.
Returns
-------
res : ndarray
Output array, with the same shape as `a`.
See Also
--------
rollaxis : Roll the specified axis backwards, until it lies in a
given position.
Examples
--------
>>> x = np.arange(10)
>>> np.roll(x, 2)
array([8, 9, 0, 1, 2, 3, 4, 5, 6, 7])
>>> np.roll(x, -2)
array([2, 3, 4, 5, 6, 7, 8, 9, 0, 1])
Activity
tdegeus commentedon Oct 4, 2019
@serge-sans-paille I do think we indeed miss
rollfor now. A PR would be very welcome ;), in particular of you're keen on starting to use it shortly.A workaround for now could be to use
padin theperiodicmode and, thenviewthe relevant section.tort-dla-psa commentedon Nov 8, 2019
I agree, it's a very useful thing to have
Implement an equivalent to numpy.roll
Implement an equivalent to numpy.roll
Implement an equivalent to numpy.roll
Implement an equivalent to numpy.roll
Implement an equivalent to numpy.roll
Implement an equivalent to numpy.roll
Implement an equivalent to numpy.roll
Implement an equivalent to numpy.roll
Implement an equivalent to numpy.roll