[Numpy-discussion] Can this be done efficiently with array functions?

Paul F. Dubois paul at pfdubois.com
Fri May 4 15:07:44 EDT 2001


-----Original Message-----
...snip

what I want is minimum.reduce(a,1), except that the zeros would be
ignored. At first glace, Masked arrays seemed the perfect option (as
that's what the zero means, no real data), but there doesn't seem to be
a minimum.reduce() in MA.

--> I'll add this to my list. Meanwhile you could do something like this,
    where x is your array:
    y = MA.masked_equal(x,0,copy=0)
    Numeric.minimum.reduce(y.filled(100000), 1)
    If x is floating point use masked_value rather than masked_equal.
---
By the way, what is the downside to Masked Arrays? they seem to be a
really powerful option. Is there any performance hit to using a masked
array over a regular onw if there is no mask? If not, would it make
sense to move toward just using Masked arrays for everything?

thanks,

-Chris

--> There are two problems. There is a hit, even in the case of no mask.
    It is hard to quantify because it depends on what operations you do.
    Much of that could be eliminated if MA was in C but it is Python.
    It would have driven me mad to write it in C, however.

    More seriously, there are a few semantic issues where it isn't clear
    what you mean if a mask is present. 








More information about the NumPy-Discussion mailing list