summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/nditer.c.src10
-rw-r--r--numpy/core/tests/test_iterator.py14
2 files changed, 15 insertions, 9 deletions
diff --git a/numpy/core/src/multiarray/nditer.c.src b/numpy/core/src/multiarray/nditer.c.src
index c4c6616a3..676d94969 100644
--- a/numpy/core/src/multiarray/nditer.c.src
+++ b/numpy/core/src/multiarray/nditer.c.src
@@ -3856,16 +3856,8 @@ operand_different_than_broadcast: {
return 0;
}
- /* Fill in the broadcast shape */
- axisdata = NIT_AXISDATA(iter);
- for (idim = 0; idim < ndim; ++idim) {
- remdims[ndim-idim-1] = NAD_SHAPE(axisdata);
-
- NIT_ADVANCE_AXISDATA(axisdata, 1);
- }
-
/* Broadcast shape */
- tmp = npyiter_shape_string(ndim, remdims, "");
+ tmp = npyiter_shape_string(ndim, broadcast_shape, "");
if (tmp == NULL) {
return 0;
}
diff --git a/numpy/core/tests/test_iterator.py b/numpy/core/tests/test_iterator.py
index f1ee95b29..fe6871cd3 100644
--- a/numpy/core/tests/test_iterator.py
+++ b/numpy/core/tests/test_iterator.py
@@ -658,6 +658,20 @@ def test_iter_broadcasting_errors():
# The message should contain the itershape parameter
assert_(msg.find('(4,3)') >= 0,
'Message "%s" doesn\'t contain itershape parameter (4,3)' % msg)
+
+ try:
+ i = nditer([np.zeros((2,1,1)), np.zeros((2,))],
+ [],
+ [['writeonly','no_broadcast'], ['readonly']])
+ assert_(False, 'Should have raised a broadcast error')
+ except ValueError, e:
+ msg = str(e)
+ # The message should contain the shape of the bad operand
+ assert_(msg.find('(2,1,1)') >= 0,
+ 'Message "%s" doesn\'t contain operand shape (2,1,1)' % msg)
+ # The message should contain the broadcast shape
+ assert_(msg.find('(2,1,2)') >= 0,
+ 'Message "%s" doesn\'t contain the broadcast shape (2,1,2)' % msg)
def test_iter_flags_errors():
# Check that bad combinations of flags produce errors