dask 2021.10.0

NotesParametersReturns
roll(array, shift, axis=None)

This docstring was copied from numpy.roll.

Some inconsistencies with the Dask version may exist.

Elements that roll beyond the last position are re-introduced at the first.

Notes

versionadded

Supports rolling over multiple dimensions simultaneously.

Parameters

a : array_like (Not supported in Dask)

Input array.

shift : int or tuple of ints

The number of places by which elements are shifted. If a tuple, then :None:None:`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 :None:None:`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.

Roll array elements along a given axis.

See Also

rollaxis

Roll the specified axis backwards, until it lies in a given position.

Examples

This example is valid syntax, but we were not able to check execution
>>> x = np.arange(10)  # doctest: +SKIP
... np.roll(x, 2) # doctest: +SKIP array([8, 9, 0, 1, 2, 3, 4, 5, 6, 7])
This example is valid syntax, but we were not able to check execution
>>> np.roll(x, -2)  # doctest: +SKIP
array([2, 3, 4, 5, 6, 7, 8, 9, 0, 1])
This example is valid syntax, but we were not able to check execution
>>> x2 = np.reshape(x, (2, 5))  # doctest: +SKIP
... x2 # doctest: +SKIP array([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]])
This example is valid syntax, but we were not able to check execution
>>> np.roll(x2, 1)  # doctest: +SKIP
array([[9, 0, 1, 2, 3],
       [4, 5, 6, 7, 8]])
This example is valid syntax, but we were not able to check execution
>>> np.roll(x2, -1)  # doctest: +SKIP
array([[1, 2, 3, 4, 5],
       [6, 7, 8, 9, 0]])
This example is valid syntax, but we were not able to check execution
>>> np.roll(x2, 1, axis=0)  # doctest: +SKIP
array([[5, 6, 7, 8, 9],
       [0, 1, 2, 3, 4]])
This example is valid syntax, but we were not able to check execution
>>> np.roll(x2, -1, axis=0)  # doctest: +SKIP
array([[5, 6, 7, 8, 9],
       [0, 1, 2, 3, 4]])
This example is valid syntax, but we were not able to check execution
>>> np.roll(x2, 1, axis=1)  # doctest: +SKIP
array([[4, 0, 1, 2, 3],
       [9, 5, 6, 7, 8]])
This example is valid syntax, but we were not able to check execution
>>> np.roll(x2, -1, axis=1)  # doctest: +SKIP
array([[1, 2, 3, 4, 0],
       [6, 7, 8, 9, 5]])
This example is valid syntax, but we were not able to check execution
>>> np.roll(x2, (1, 1), axis=(1, 0))  # doctest: +SKIP
array([[9, 5, 6, 7, 8],
       [4, 0, 1, 2, 3]])
This example is valid syntax, but we were not able to check execution
>>> np.roll(x2, (2, 1), axis=(1, 0))  # doctest: +SKIP
array([[8, 9, 5, 6, 7],
       [3, 4, 0, 1, 2]])
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /dask/array/routines.py#1796
type: <class 'function'>
Commit: