[SciPy-dev] PEP: Improving the basic statistical functions in Scipy
Pierre GM
pgmdevlist@gmail....
Fri Feb 27 16:47:08 CST 2009
On Feb 27, 2009, at 4:52 PM, josef.pktd@gmail.com wrote:
>
> For most of the current statistical functions, with the exception of
> different tie handling, I think that we can expand the _chk_asarray to
> do the necessary preprocessing.
Mmh. _chk_asarray will always return a MA. Is it what you want? Are you
An idea is then to use the 'usemask' parameter I was talking about
earlier:
* if usemask is False (default), return a ndarray
* If usemask is True, return a MA
* if the input is a MA (w/ or w/o missing values), set usemask to
True, and mask the NaNs/Infs first w/ ma.fix_invalid.
That way, we need only one function. If we really need it, we can have
duplicate functions in scipy.mstats where usemask is set to True by
default.
Now, for the actual implementation:
* usemask=False and some NaNs: return NaN
* usemask=True: use the ma implementation.
>>>> stats.mstats.moment(np.ma.fix_invalid(np.ma.column_stack([x,x])),
>>>> 1) #inconsistent return type
> array([ 0., 0.])
That's a bug, we should have a MA.
More information about the Scipy-dev
mailing list