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

Benjamin Root ben.root@ou....
Wed Feb 1 14:09:54 CST 2012


2012/2/1 martin großhauser <mgroszhauser@gmail.com>

> 2012/2/1 martin großhauser <mgroszhauser@gmail.com>:
> > Hello,
> >
> > when I try in my script to divide a masked array by a scalar I get an
> > error. The instruction is:
> >
> >>> sppa = sp / 100.
> >
> > sp is a masked array with ndim = 3.
> >
> > error is:
> > Traceback (most recent call last):
> >  File "/media/nethome/Work/workspace/interimEnso/src/mlBudget.py",
> > line 95, in <module>
> >    sppa = sp / 100.
> >  File "/usr/lib/pymodules/python2.7/numpy/ma/core.py", line 3673, in
> __div__
> >    return divide(self, other)
> >  File "/usr/lib/pymodules/python2.7/numpy/ma/core.py", line 1072, in
> __call__
> >    m |= ma
> > ValueError: invalid return array shape
> >
> > The interesting thing is that this error only occurs after a tiling
> instruction:
> >>>         sp4d = N.tile(sp, (ninterf, 1, 1, 1))
> >
> > If I do the division before the tiling I don't get an error. There's
> > also no error if I do the division with N.divide(sp, 100.).
> >
> > Also printing the array sp after tiling doesn't work, while it works
> > before. If I debug the script with eclipse/PyDev, in the variables
> > window I get the message "Unable to get repr for <class
> > 'numpy.ma.core.MaskedArray'>" for the sp array after tiling.
> >
> > The tiling operation shouldn't change the array, should it? Is this a
> > bug, or is it expected behaviour?
> >
> > Regards,
> > Martin Groszhauser
>
> I forgot to mention that I'm using Numpy 1.5.1 from Ubuntu 11.04
> (1.5.1-1ubuntu2).
>

I can't reproduce this bug with the latest numpy from github master.
Perhaps it has been fixed by now?

Ben Root
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120201/51b9a200/attachment.html 


More information about the NumPy-Discussion mailing list