diff options
-rw-r--r-- | numpy/core/tests/test_iterator.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/numpy/core/tests/test_iterator.py b/numpy/core/tests/test_iterator.py index e5a073e12..d29c2adfb 100644 --- a/numpy/core/tests/test_iterator.py +++ b/numpy/core/tests/test_iterator.py @@ -2218,6 +2218,25 @@ def test_iter_reduction(): assert_equal(i.operands[1].ndim, 0) assert_equal(i.operands[1], np.sum(a)) + # This is a tricky reduction case for the buffering double loop + # to handle + a = np.ones((2,3,5)) + it1 = nditer([a,None], ['reduce_ok','external_loop'], + [['readonly'], ['readwrite','allocate']], + op_axes=[None,[0,-1,1]]) + it2 = nditer([a,None], ['reduce_ok','external_loop', + 'buffered','delay_bufalloc'], + [['readonly'], ['readwrite','allocate']], + op_axes=[None,[0,-1,1]], buffersize=10) + it1.operands[1].fill(0) + it2.operands[1].fill(0) + it2.reset() + for x in it1: + x[1][...] += x[0] + for x in it2: + x[1][...] += x[0] + assert_equal(it1.operands[1], it2.operands[1]) + assert_equal(it2.operands[2].sum(), a.size) def test_iter_buffering_reduction(): # Test doing buffered reductions with the iterator |