summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
diff options
context:
space:
mode:
authorvinith2 <85550536+vinith2@users.noreply.github.com>2021-11-01 22:34:56 +0100
committerGitHub <noreply@github.com>2021-11-01 14:34:56 -0700
commit987d25bebb3564eca4a86712ccdeba93016758ed (patch)
tree25bf2f89361f4aba7297f93eefcdca945a7578b3 /numpy/core/numeric.py
parentf4d96a718eb56612e2a2fdac985f21075acb15db (diff)
downloadnumpy-987d25bebb3564eca4a86712ccdeba93016758ed.tar.gz
DOC: Add multi-axis examples to numpy.roll docstring (#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 <rossbar@berkeley.edu>
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r--numpy/core/numeric.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index d8a0cf9a6..1654e8364 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -1184,7 +1184,7 @@ def roll(a, shift, axis=None):
>>> np.roll(x, -2)
array([2, 3, 4, 5, 6, 7, 8, 9, 0, 1])
- >>> x2 = np.reshape(x, (2,5))
+ >>> x2 = np.reshape(x, (2, 5))
>>> x2
array([[0, 1, 2, 3, 4],
[5, 6, 7, 8, 9]])
@@ -1206,6 +1206,12 @@ def roll(a, shift, axis=None):
>>> np.roll(x2, -1, axis=1)
array([[1, 2, 3, 4, 0],
[6, 7, 8, 9, 5]])
+ >>> np.roll(x2, (1, 1), axis=(1, 0))
+ array([[9, 5, 6, 7, 8],
+ [4, 0, 1, 2, 3]])
+ >>> np.roll(x2, (2, 1), axis=(1, 0))
+ array([[8, 9, 5, 6, 7],
+ [3, 4, 0, 1, 2]])
"""
a = asanyarray(a)