On Sat, Jun 25, 2011 at 12:17 PM, Wes McKinney <wesmck...@gmail.com> wrote:

>
> Agree. My basic observation about numpy.ma is that it's a finely
> crafted solution for a different set of problems than the ones I have.
> I just don't want the same thing to happen here so I'm stuck writing
> code (like I am now) that looks like
>
> mask = y.mask
> the_sum = y.sum(axis)
> the_count = mask.sum(axis)
> the_sum[the_count == 0] = nan
>
>
Yeah, you are expecting NaN behavior there, in which case, using NaNs
without masks is fine.  But, for a general solution, you might want to
consider that masked_array provides a "recordmask" as well as a mask.
Although, the documentation is very lacking, and using masked arrays with
record arrays seems very clumsy, but that is certainly something that could
get cleaned up.

Also, as a cleaner version of your code:

the_sum = y.sum(axis)
the_sum.mask = np.any(y.mask, axis)
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to