Skip to content

Commit 987d25b

Browse files
vinith2rossbar
andauthored
DOC: Add multi-axis examples to numpy.roll docstring (numpy#20267)
Added exampled where we use tuple in for axis and shifts separately. This shows how the multiple shift examples works Co-authored-by: Ross Barnowski <[email protected]>
1 parent f4d96a7 commit 987d25b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

numpy/core/numeric.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ def roll(a, shift, axis=None):
11841184
>>> np.roll(x, -2)
11851185
array([2, 3, 4, 5, 6, 7, 8, 9, 0, 1])
11861186
1187-
>>> x2 = np.reshape(x, (2,5))
1187+
>>> x2 = np.reshape(x, (2, 5))
11881188
>>> x2
11891189
array([[0, 1, 2, 3, 4],
11901190
[5, 6, 7, 8, 9]])
@@ -1206,6 +1206,12 @@ def roll(a, shift, axis=None):
12061206
>>> np.roll(x2, -1, axis=1)
12071207
array([[1, 2, 3, 4, 0],
12081208
[6, 7, 8, 9, 5]])
1209+
>>> np.roll(x2, (1, 1), axis=(1, 0))
1210+
array([[9, 5, 6, 7, 8],
1211+
[4, 0, 1, 2, 3]])
1212+
>>> np.roll(x2, (2, 1), axis=(1, 0))
1213+
array([[8, 9, 5, 6, 7],
1214+
[3, 4, 0, 1, 2]])
12091215
12101216
"""
12111217
a = asanyarray(a)

0 commit comments

Comments
 (0)