diff options
author | Pauli Virtanen <pav@iki.fi> | 2016-09-11 14:58:40 +0200 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2017-01-19 22:12:47 +0100 |
commit | 0bff7b30466b26963cf4fc1b280eb207b74e9851 (patch) | |
tree | 180623c77ce0230c80a8acb9fe40a3248a3ce8f7 /numpy/core/tests/test_mem_overlap.py | |
parent | dae0b12d6a790543bee4002f434a1633f8923188 (diff) | |
download | python-numpy-0bff7b30466b26963cf4fc1b280eb207b74e9851.tar.gz python-numpy-0bff7b30466b26963cf4fc1b280eb207b74e9851.tar.bz2 python-numpy-0bff7b30466b26963cf4fc1b280eb207b74e9851.zip |
ENH: core: handle memory overlap in ufunc.at
This adds a new method PyArray_MapIterArrayCopyIfOverlap to the API.
Diffstat (limited to 'numpy/core/tests/test_mem_overlap.py')
-rw-r--r-- | numpy/core/tests/test_mem_overlap.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/numpy/core/tests/test_mem_overlap.py b/numpy/core/tests/test_mem_overlap.py index 07b1346cb..a5cb5a4f5 100644 --- a/numpy/core/tests/test_mem_overlap.py +++ b/numpy/core/tests/test_mem_overlap.py @@ -750,6 +750,30 @@ class TestUFunc(object): if (c != cx).any(): assert_equal(c, cx) + def test_ufunc_at_manual(self): + def check(ufunc, a, ind, b=None): + a0 = a.copy() + if b is None: + ufunc.at(a0, ind.copy()) + c1 = a0.copy() + ufunc.at(a, ind) + c2 = a.copy() + else: + ufunc.at(a0, ind.copy(), b.copy()) + c1 = a0.copy() + ufunc.at(a, ind, b) + c2 = a.copy() + assert_array_equal(c1, c2) + + # Overlap with index + a = np.arange(10000, dtype=np.int16) + check(np.invert, a[::-1], a) + + # Overlap with second data array + a = np.arange(100, dtype=np.int16) + ind = np.arange(0, 100, 2, dtype=np.int16) + check(np.add, a, ind, a[25:75]) + def test_unary_ufunc_1d_manual(self): # Exercise branches in PyArray_EQUIVALENTLY_ITERABLE |