[Numpy-discussion] Broadcasting doesn't work with divide after tile

martin großhauser mgroszhauser@gmail....
Thu Feb 2 02:52:38 CST 2012

On Wed, Feb 1, 2012 at 10:57 PM, Pierre Haessig
<pierre.haessig@crans.org> wrote:
> I've no idea what's going on, but here is my $0.02 contribution. I
> reproduced the bug (numpy 1.5.1) with a rather minimal script. See attached.

I reproduced the issue with Pierre's script also in numpy 1.6.1 and
latest github (2.0.0.dev-b8bfcd0). In newer versions the error message

Traceback (most recent call last):
  File "ma_tiling_issue.py", line 18, in <module>
    a/100. #raises ValueError: invalid return array shape
  File "/usr/local/lib/python2.7/dist-packages/numpy/ma/core.py", line
3654, in __div__
    return divide(self, other)
  File "/usr/local/lib/python2.7/dist-packages/numpy/ma/core.py", line
1078, in __call__
    m |= ma
ValueError: non-broadcastable output operand with shape (3,3,3)
doesn't match the broadcast shape (1,3,3,3)

I still don't know what's going on. Is the internal representation
(shape) of the array changed by the tile instruction?

I created a ticket: http://projects.scipy.org/numpy/ticket/2035

More information about the NumPy-Discussion mailing list