diff options
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/lib/function_base.py | 3 | ||||
| -rw-r--r-- | numpy/lib/tests/test_function_base.py | 4 | ||||
| -rw-r--r-- | numpy/ma/core.py | 4 | ||||
| -rw-r--r-- | numpy/ma/tests/test_core.py | 9 |
4 files changed, 17 insertions, 3 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 399f761ba..1ead53c87 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -3695,7 +3695,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 " diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index ca329aae6..45e248913 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -232,6 +232,10 @@ class TestInsert(TestCase): a = np.array(1).view(SubClass) assert_(isinstance(np.insert(a, 0, [0]), SubClass)) + def test_index_array_copied(self): + x = np.array([1, 1, 1]) + np.insert([0, 1, 2], x, [3, 4, 5]) + assert_equal(x, np.array([1, 1, 1])) class TestAmax(TestCase): def test_basic(self): diff --git a/numpy/ma/core.py b/numpy/ma/core.py index e1e848206..38076e8b3 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -3438,12 +3438,12 @@ class MaskedArray(ndarray): return np.asanyarray(fill_value) # if m.dtype.names: - result = self._data.copy() + result = self._data.copy('K') _recursive_filled(result, self._mask, fill_value) elif not m.any(): return self._data else: - result = self._data.copy() + result = self._data.copy('K') try: np.copyto(result, fill_value, where=m) except (TypeError, AttributeError): diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index f14891087..263a9735a 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -537,6 +537,15 @@ class TestMaskedArray(TestCase): assert_equal(test, control) + def test_filled_w_f_order(self): + "Test filled w/ F-contiguous array" + a = array(np.array([(0, 1, 2), (4, 5, 6)], order='F'), + mask=np.array([(0, 0, 1), (1, 0, 0)], order='F'), + order='F') # this is currently ignored + self.assertTrue(a.flags['F_CONTIGUOUS']) + self.assertTrue(a.filled(0).flags['F_CONTIGUOUS']) + + def test_optinfo_propagation(self): "Checks that _optinfo dictionary isn't back-propagated" x = array([1, 2, 3, ], dtype=float) |
