[Numpy-discussion] Bug with MA and reduce?
Ludwig M Brinckmann
Fri Jul 27 09:35:34 CDT 2007
This is a follow-up to an earlier mail that reported a suspected bug in the
reduce/minimum operation of numpy.ma.
I have tried the same code with the scipy sandbox maskedarray implementation
and that gives me the correct output. For comparison:
# import numpy.core.ma as MA
import maskedarray as MA
shape = (100)
data = numpy.ones(shape, numpy.int16)
data[2:40] = 3
data[45:70] = -999
mask = MA.make_mask_none(data.shape)
mask[data == -999] = True
ma = MA.MaskedArray(data, mask = mask)
min = MA.minimum.reduce(ma,0)
With maskedarray I get, as expected 1, with numpy.core.ma I get -1, a value
that is not in the array.
I am using Python 2.44 on XP, the maskedarray is the svn latest, the
numpy.core.ma was 1.0.2, but I have tested it with only the current svn
version of ma.py and it produces the wrong output.
On 27/07/07, Ludwig M Brinckmann <email@example.com> wrote:
> I have ma.minimum.reduce return a minimum value that does not exist in the
> The following code prints -1 as the minimum of the MA, I believe it should
> be 1.
> import numpy
> shape = (100)
> data = numpy.ones (shape, numpy.int16)
> data[2:40] = 3 # dummy data
> data[45:70] = -999 # null values
> mask = numpy.ma.make_mask_none(data.shape)
> mask[data == -999] = True
> ma = numpy.ma.MaskedArray(data, mask = mask)
> min = numpy.ma.minimum.reduce(ma,0)
> print min
> Am I doing something really stupid here?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion