[Numpy-discussion] behavior of masked arrays
Pierre GM
pgmdevlist@gmail....
Sun Mar 9 12:40:09 CDT 2008
On Sunday 09 March 2008 13:35:27 Giorgio F. Gilestro wrote:
> Pierre, I did some adjusting to some of the functions in
> scipy.stats.stats and more I am planning to do - not all but those I'll
> need I am afraid. Is it ok if I send you what I'll have so that you have
> a look at it (at your convenience) and maybe integrate it to
> numpy.ma.mstats?
Sure, no problem. I foresee a reorganization of numpy.ma.mstats in the near
future, with most functions being sent to a scipy.stats.mstats package
instead. mmedian would be introduced in core for compatibility with numpy.
> For the moment the only issues I met are:
>
> - some functions require to know N, the number of elements on which we
> are performing the operation. A simple N.shape[axis] won't work but
> there is no native method returning the number of unmasked elements on a
> given axis (maybe there should be?). So I am using instead
>
> N = a.shape[axis] - a.mask.sum(axis)
Well, you can count the number of missing values along a given axis with
self.count(axis), so the number of unmasked values is simply
self.shape[axis]-self.count(axis)
> - some functions need to handle float data. The float method on masked
> array will raise an exception (why so?) so I am either introducing float
> constant where possible
Mmh, what float method ? If you're using the regular float function, that
should work on 0d arrays, with nan being returned if you have a masked
values.
More information about the Numpy-discussion
mailing list