diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2013-04-26 23:26:58 +0200 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2013-04-27 11:49:04 +0200 |
commit | 0a9da01121b0f13d4e87fa44fbff7ba04472e314 (patch) | |
tree | 2f255d7c8254243ea086c8b744042b02d6068367 /numpy/lib/function_base.py | |
parent | 6ffa2ea9744e01129382b902649edfd50e848401 (diff) | |
download | numpy-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.py | 3 |
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 " |