summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2013-04-26 23:26:58 +0200
committerSebastian Berg <sebastian@sipsolutions.net>2013-04-27 11:49:04 +0200
commit0a9da01121b0f13d4e87fa44fbff7ba04472e314 (patch)
tree2f255d7c8254243ea086c8b744042b02d6068367 /numpy/lib/function_base.py
parent6ffa2ea9744e01129382b902649edfd50e848401 (diff)
downloadnumpy-0a9da01121b0f13d4e87fa44fbff7ba04472e314.tar.gz
BUG: np.insert must copy index array
Otherwise it would do in-place changes to it. Fixes gh-3279.
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r--numpy/lib/function_base.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 43bd3af8b..500394a38 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -3694,7 +3694,8 @@ def insert(arr, obj, values, axis=None):
# turn it into a range object
indices = arange(*obj.indices(N),**{'dtype':intp})
else:
- indices = np.asarray(obj)
+ # need to copy obj, because indices will be changed in-place
+ indices = np.array(obj)
if indices.dtype == bool:
# See also delete
warnings.warn("in the future insert will treat boolean arrays "