diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2013-12-02 13:47:46 +0100 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2013-12-02 13:47:46 +0100 |
commit | 50fad03b2ab81d9518e95138f2425ecd82740be3 (patch) | |
tree | 2551981455c0cb8ae7abb0179cdd55802bc61625 /numpy/lib/function_base.py | |
parent | f4749b7b2514db9f12978438a2131df981dc14d6 (diff) | |
download | numpy-50fad03b2ab81d9518e95138f2425ecd82740be3.tar.gz |
BUG: Fix np.insert with negative axis.
In some cases a negative axis argument to np.insert would result
in wrong behaviour due to np.rollaxis, add modulo operation to
avoid this (an error is still raised due to arr.shape[axis]).
Closes gh-3494
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 9176d9950..db0c5ffbb 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -3607,7 +3607,7 @@ def insert(arr, obj, values, axis=None): # broadcasting is very different here, since a[:,0,:] = ... behaves # very different from a[:,[0],:] = ...! This changes values so that # it works likes the second case. (here a[:,0:1,:]) - values = np.rollaxis(values, 0, axis + 1) + values = np.rollaxis(values, 0, (axis % values.ndim) + 1) numnew = values.shape[axis] newshape[axis] += numnew new = empty(newshape, arr.dtype, arr.flags.fnc) |