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

martin großhauser mgroszhauser@gmail....
Wed Feb 1 10:53:52 CST 2012


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

If I try to print the


More information about the NumPy-Discussion mailing list