summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
diff options
context:
space:
mode:
authorDenis Laxalde <denis@laxalde.org>2012-05-08 15:23:42 -0400
committerDenis Laxalde <denis@laxalde.org>2012-05-08 15:34:55 -0400
commitbe90de8e31b76db8154e8ab9cefc21c1d25d0f45 (patch)
treea4a39ecd92ae1c47499a21f31ec19579de527376 /numpy/core/numeric.py
parent37fab7a8fcf72653289a3a3453130696977eb0f7 (diff)
downloadnumpy-be90de8e31b76db8154e8ab9cefc21c1d25d0f45.tar.gz
FIX: handle empty arrays in roll
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r--numpy/core/numeric.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 8212dd6ce..d26d9ded8 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -1184,13 +1184,16 @@ def roll(a, shift, axis=None):
except IndexError:
raise ValueError('axis must be >= 0 and < %d' % a.ndim)
reshape = False
- shift %= n
- indexes = concatenate((arange(n-shift,n),arange(n-shift)))
- res = a.take(indexes, axis)
- if reshape:
- return res.reshape(a.shape)
+ if n == 0:
+ return a
else:
- return res
+ shift %= n
+ indexes = concatenate((arange(n-shift,n),arange(n-shift)))
+ res = a.take(indexes, axis)
+ if reshape:
+ return res.reshape(a.shape)
+ else:
+ return res
def rollaxis(a, axis, start=0):
"""