diff options
author | Mark Wiebe <mwwiebe@gmail.com> | 2011-05-18 05:42:32 -0500 |
---|---|---|
committer | Mark Wiebe <mwwiebe@gmail.com> | 2011-05-18 05:42:32 -0500 |
commit | cbca2458d9ade3c624d29bb1b27451af0c47372a (patch) | |
tree | 6addf7b0859a8a832a60d9b6fae16f20dade708d | |
parent | 5c4efaac91413ef14a558098197f1e85d19309ef (diff) | |
download | numpy-cbca2458d9ade3c624d29bb1b27451af0c47372a.tar.gz |
TST: Reduced test case for ticket #1834
The ticket's bug is visible in einsum, but is caused by an error in how
the reduction double loop interacts with buffering in the nditer. This
test case directly tests the nditer triggering the bad code.
-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 |