[SciPy-dev] scipy.stats._chk_asarray
Pierre GM
pgmdevlist@gmail....
Tue Jun 2 23:50:13 CDT 2009
On Jun 2, 2009, at 11:09 PM, josef.pktd@gmail.com wrote:
>> I tried to see if I can introduce a second version _check_asanyarray,
> that doesn't convert to basic np.array, but I didn't get very far.
> nanmedian, and nanstd are not easy to convert to work with matrices,
> nanstd uses multiplication and nanmedian uses np.compress
Well, what about that:
* convert the inputs to ndarray w/ _chk_asarray
* compute as usual
* return a view of the result using the type of the input (using the
type keyword of view)
That should work w/ nanmedian. There might be some adjustment to make
for nanstd (pb of dimensions?)
>
> Doing a variation on it seems to work for matrices, see below. I
> haven't tried it on other array types. This is just a trial balloon to
> see whether this would make sense for some of the stats functions. It
> would be relevant mostly for the descriptive statistics, the
> statistical tests just return test statistics and pvalues, the plan
> for models is that they get explicit array subclass handling.
>
> Is this a good idea to try to work this way?
Have you checked the sources of numpy.ma ? Most of the functions are
actually instances of some factory class that take the mask and input
class into account, something pretty close to your wrapit function.
I'm just mentioning that because it'd be nice if the new functions
worked on MaskedArray and its subclasses as well (or at least work in
the general case, I wouldn't mind taking care of the corner cases)
> And what is the best way to check whether an array is a plain ndarray
> and not a subclass instance?
Er, why do you want to do that ?
Oh, about array_priority: could you set it to something higher than 1
but less than 15 (the current ma.MaskedArray._-array_priority__ ?)
More information about the Scipy-dev
mailing list