[Numpy-discussion] Preventing an ndarray subclass from returning new subclass instances for std(), etc
Keith Hughitt
keith.hughitt@gmail....
Sun Sep 18 11:48:45 CDT 2011
Interesting. It works as expected when called as a method:
In [10]: x = np.ma.array([[1,2,3]])
In [11]: x.std()
Out[11]: 0.81649658092772603
but not for my class:
In [14]: aia.std()
Out[14]: AIAMap(292.4342470467856)
In [15]: np.std(aia)
Out[15]: AIAMap(292.4342470467856)
In [16]: np.array(aia).std()
Out[16]: 292.43424704678557
Keith
2011/9/18 Stéfan van der Walt <stefan@sun.ac.za>
> On Sun, Sep 18, 2011 at 9:09 AM, Keith Hughitt <keith.hughitt@gmail.com>
> wrote:
> > I'm sure it is simply a coding error on my part, but so far I havne't
> been
> > able to track it down.
>
> I don't think it's something you've done wrong. See e.g.:
>
> In [9]: x = np.ma.array([[1,2,3]])
>
> In [10]: np.std(x, axis=0)
> Out[10]:
> masked_array(data = [0.0 0.0 0.0],
> mask = [False False False],
> fill_value = 1e+20)
>
> Regards
> Stéfan
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110918/09026962/attachment.html
More information about the NumPy-Discussion
mailing list