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

Pierre GM pgmdevlist@gmail....
Fri Jan 4 14:20:11 CST 2008


On Friday 04 January 2008 12:01:14 Alexander Michael wrote:
> Concretely, this is how I would write my own prod function:
>
> def ma_prod(a):
>     p = 1.0
>     for x in a.data[~a.mask]:
>         p *= x
>     return p

Which would work only in 1D, as you mentioned.

> All the CS mumbo-jumbo aside, the real question appears to be are fully
> masked arrays empty or undefined? I would consider them conceptually empty,
> if only because it makes for a convenient continuity as the number of
> masked elements increases from one to the whole of the array.

That's a way to see it. Personally, I'm happy with this behavior: getting 
masked as the result of .sum() tells me that all the initial values were 
masked, which is not the same thing as getting 0.

> Thanks for the hard work on the new MaskedArray. I'm attempting to be
> constructive by raising these issues, so please let me know if my comments
> are otherwise.

Oh please, thanks a lot for your contributions ! Another issue is that we need 
to ensure compatibility with the previous version of maskedarray 
(numpy.core.ma). At the end, that's what matters.


More information about the Numpy-discussion mailing list