diff options
author | Matti Picus <matti.picus@gmail.com> | 2019-02-18 20:19:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-18 20:19:55 +0200 |
commit | 1dfb0ab7358b0cae068b41b3d07452713594ef6b (patch) | |
tree | c992557478c513c5a2f77d9318e321f9b4739ebf /numpy/core/numeric.py | |
parent | 5d122da3fb61eb09662e51f016f59250ee39b30c (diff) | |
parent | 22f61e9886411d0e58a2fdd1afc364c320b41efc (diff) | |
download | numpy-1dfb0ab7358b0cae068b41b3d07452713594ef6b.tar.gz |
Merge pull request #12984 from Bharat123rox/update-doc
DOC: Fix #12959 by including negative shifts in np.roll
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r-- | numpy/core/numeric.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 1b8f36c3e..c06b0cf98 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -1443,7 +1443,9 @@ def roll(a, shift, axis=None): >>> 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]) + >>> x2 = np.reshape(x, (2,5)) >>> x2 array([[0, 1, 2, 3, 4], @@ -1451,12 +1453,21 @@ def roll(a, shift, axis=None): >>> np.roll(x2, 1) array([[9, 0, 1, 2, 3], [4, 5, 6, 7, 8]]) + >>> np.roll(x2, -1) + array([[1, 2, 3, 4, 5], + [6, 7, 8, 9, 0]]) >>> np.roll(x2, 1, axis=0) array([[5, 6, 7, 8, 9], [0, 1, 2, 3, 4]]) + >>> np.roll(x2, -1, axis=0) + array([[5, 6, 7, 8, 9], + [0, 1, 2, 3, 4]]) >>> np.roll(x2, 1, axis=1) array([[4, 0, 1, 2, 3], [9, 5, 6, 7, 8]]) + >>> np.roll(x2, -1, axis=1) + array([[1, 2, 3, 4, 0], + [6, 7, 8, 9, 5]]) """ a = asanyarray(a) |