diff options
author | Bharat123Rox <bharatr@symphonyai.com> | 2019-02-18 20:55:40 +0530 |
---|---|---|
committer | Bharat123Rox <bharatr@symphonyai.com> | 2019-02-18 20:55:40 +0530 |
commit | 60981410a6be95db211491e76190259ca41b03a0 (patch) | |
tree | 879a46820f25c3b8e0919a4e5399fe06d0530261 /numpy/core/numeric.py | |
parent | 8063fa6d1b92a755db9727b17428eb19e0ba590f (diff) | |
download | numpy-60981410a6be95db211491e76190259ca41b03a0.tar.gz |
DOC: Fix numpy#12959 by including negative shifts
Included examples symmetric to the existing ones in np.roll with negative shifts.
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r-- | numpy/core/numeric.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 1b8f36c3e..f214eb603 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -1443,7 +1443,8 @@ 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 +1452,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) |