[Numpy-discussion] Questions about masked arrays

Gökhan Sever gokhansever@gmail....
Tue Oct 6 20:54:16 CDT 2009

On Tue, Oct 6, 2009 at 7:38 PM, Pierre GM <pgmdevlist@gmail.com> wrote:

> On Oct 6, 2009, at 6:57 PM, Gökhan Sever wrote:
> > Seeing a different filling value is causing confusion. Both for
> > myself, and when I try to demonstrate the usage of masked array to
> > other people.
> Fair enough. I must admit that `fill_value` is a vestige from the
> previous implementation (talking pre 1.2 here), that is no longer
> really needed (cf below for more details).
> > Also say, if I want to replace that one element back to its original
> > state will it use fill_value as 1e+20 or 999999.9999?
> What do you mean by 'replace back to its original state' ? Using
> `filled`, you mean ?

Yes, in more properly stated fashion "filled" :)

I[14]: c.data['Air_Temp'][4]
masked_array(data = --,
             mask = True,
       fill_value = 1e+20)

I[15]: c.data['Air_Temp'][4].filled()
O[15]: array(1e+20)

Little buggy, isn't it? It properly fill the whole array:

I[13]: c.data['Air_Temp'].filled()
array([  1.31509000e+01,   1.31309000e+01,   1.31278000e+01,
         1.31542000e+01,   1.00000000e+06,   1.31539000e+01,
         1.31387000e+01,   1.00000000e+06,   1.00000000e+06,
         1.00000000e+06,   1.31107000e+01,   1.31351000e+01,
         1.32073000e+01,   1.32562000e+01,   1.33533000e+01,
         1.33889000e+01,   1.34067000e+01,   1.32938000e+01,
         1.31962000e+01,   1.31248000e+01,   1.30411000e+01,
         1.29534000e+01,   1.28354000e+01,   1.27392000e+01,

> > > 2-) What is wrong with the arccos calculation? Should not that
> > > result the same as with cos(d) result?
> >
> > I first tested on 1.3.0, and later on my laptop using 1.4dev version
> > which is about an old month built.
> >
> > Once again the results for each arc... function
> Er, I assume it's np.arccos ?

Sorry too much time spent in ipython -pylab :)

I[18]: arccos?
Type:             ufunc
Base Class:       <type 'numpy.ufunc'>
String Form:   <ufunc 'arccos'>
Namespace:        Interactive
File:             /home/gsever/Desktop/python-repo/numpy/numpy/__init__.py

> Anyway, I'm puzzled. Works like a charm here (r7438 for numpy.ma).
> Could it be that something went wrng with some ufuncs ?

This I don't know :(

> I didn't touch
> ma since 09/08 (thanks, svn history), so I don't think it comes from
> here...

Yes, SVN is a very useful invention indeed.

I[6]: numpy.__version__
O[6]: '1.4.0.dev'

For some reason it doesn't list check-out revision.

Doing an ls -l reveals that those are checked-out and installed after August
13 which was a preparation for the SciPy 09 :)

Would you mind trying a more recent svn version ?

This is the last resort. I will eventually try this if I don't any other
options left.

I confirmed the same arccos weirdness in Sage Notebook (www.sagenb.org)
where Numpy 1.3.0 is installed there.

> _______________________________________________
> 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/20091006/7acf3548/attachment.html 

More information about the NumPy-Discussion mailing list