summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorMark Wiebe <mwwiebe@gmail.com>2011-03-13 23:58:35 -0700
committerMark Wiebe <mwwiebe@gmail.com>2011-03-13 23:58:35 -0700
commit6c7d3dd3fda1602a30a0fd44fa9a35494e40b045 (patch)
tree664aa4d825452096f48fd25c3aa3e12170e1e844 /numpy
parent2b9dfd49218c553fc22ba8665a5e9034a36777f1 (diff)
downloadnumpy-6c7d3dd3fda1602a30a0fd44fa9a35494e40b045.tar.gz
BUG: Another iterator broadcasting error message had a reversed shape
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/nditer.c.src2
-rw-r--r--numpy/core/tests/test_iterator.py17
2 files changed, 18 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/nditer.c.src b/numpy/core/src/multiarray/nditer.c.src
index 559a6f2e5..dd8285242 100644
--- a/numpy/core/src/multiarray/nditer.c.src
+++ b/numpy/core/src/multiarray/nditer.c.src
@@ -3736,7 +3736,7 @@ broadcast_error: {
if (axes != NULL) {
for (idim = 0; idim < ndim; ++idim) {
- npy_intp i = axes[ndim-idim-1];
+ npy_intp i = axes[idim];
if (i >= 0 && i < PyArray_NDIM(op[iiter])) {
remdims[idim] = PyArray_DIM(op[iiter], i);
diff --git a/numpy/core/tests/test_iterator.py b/numpy/core/tests/test_iterator.py
index 1c12f6b55..818b15524 100644
--- a/numpy/core/tests/test_iterator.py
+++ b/numpy/core/tests/test_iterator.py
@@ -641,6 +641,23 @@ def test_iter_broadcasting_errors():
assert_(msg.find('(1,2,3)') >= 0,
'Message "%s" doesn\'t contain broadcast shape (1,2,3)' % msg)
+ try:
+ i = nditer([arange(6).reshape(2,3), arange(2)], [],
+ [['readonly'],['readonly']],
+ op_axes=[[0,1], [0,np.newaxis]],
+ itershape=(4,3))
+ assert_(False, 'Should have raised a broadcast error')
+ except ValueError, e:
+ msg = str(e)
+ # The message should contain "shape->remappedshape" for each operand
+ assert_(msg.find('(2,3)->(2,3)') >= 0,
+ 'Message "%s" doesn\'t contain operand shape (2,3)->(2,3)' % msg)
+ assert_(msg.find('(2)->(2,newaxis)') >= 0,
+ ('Message "%s" doesn\'t contain remapped operand shape' +
+ '(2)->(2,newaxis)') % msg)
+ # The message should contain the itershape parameter
+ assert_(msg.find('(4,3)') >= 0,
+ 'Message "%s" doesn\'t contain itershape parameter (4,3)' % msg)
def test_iter_flags_errors():
# Check that bad combinations of flags produce errors