[Numpy-discussion] MaskedArray and the min, max, sum, prod Methods

Alexander Michael lxander.m@gmail....
Fri Jan 4 09:27:32 CST 2008


On Jan 4, 2008 10:01 AM, Pierre GM <pgmdevlist@gmail.com> wrote:
> On Thursday 03 January 2008 15:49:45 Alexander Michael wrote:
> > Working with the new MaskedArray, I noticed the following differences
> >
> > with numpy.array behavior:
> > >>> masked_array([1, 2, 3], mask=True).min()
> >
> > 2147483647
>
> That's a bug, the result should be maskedarray.masked. Samething for max, of
> course.
>
> > >>> masked_array([1, 2, 3], mask=True).prod()
> >
> > masked_array(data = --,
> >       mask = True,
> >       fill_value=1e+020)
> >
> > >>> array([]).prod()
> >
> > 1.0
>
> That's OK here, the result is maskedarray.masked. Ditto for sum

Hmm. I liked the base ndarray behavior as it makes a lot of sense to
me and provides an easy default that avoids needing to check the
result between steps. Does MaskedArray do this to be compatible
with the original ma, or is there a theoretically good reason for it
that I am missing?

Thanks!
Alex


More information about the Numpy-discussion mailing list