[Numpy-discussion] Questions about masked arrays

Gökhan Sever gokhansever at gmail.com
Tue Oct 6 22:58:26 EDT 2009


On Tue, Oct 6, 2009 at 9:22 PM, Pierre GM <pgmdevlist at gmail.com> wrote:

>
> On Oct 6, 2009, at 9:54 PM, Gökhan Sever wrote:
> >
> > > 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]
> > O[14]:
> > 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()
> > O[13]:
> > 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,
> >          1.26725000e+01])
>
> Once again, when you access your 5th element, you get the special
> `masked` constant. If you fill this constant, you'll get something
> which is probably not what you want. And I would need a *REALLY*
> compelling reason to change this behavior, as it's gonna break a lot
> of things (the masked constant has been around for a while)
>
>
I see your points. I don't want to give you extra work, don't worry :) It
just seem a bit bizarre:

I[27]: c.data['Air_Temp'].fill_value
O[27]: 999999.99990000005

I[28]: c.data['Air_Temp'][4].fill_value
O[28]: 1e+20

As you see, it just returns two different fill_values. I know eventually you
will be the one handling this :) it might be good to add this issue to the
tracker.




> > > > 2-) What is wrong with the arccos calculation? Should not that
> >
> > Er, I assume it's np.arccos ?
> >
> > Sorry too much time spent in ipython -pylab :)
>
> Well, i use ipython -pylab regularly as well, but still have the
> reflex of using np. ;)
>
>
>
Good reflex. Saves you from making extra explanations. But it works with
just typing array why should I type np.array (Ohh my namespacess :)

It is just an IPython magic.


>
> >
> > 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.
>
> I know, and it's bugging me as well. if you have a build directory
> somewhere, check numpy/core/__svn_version__.py
>
>
There is build directory but no files that contains svn :(


> > This is the last resort. I will eventually try this if I don't any
> > other options left.
>
> I gonna have difficulties fixing something that I don't see broken...
> Now, there might be something wrong in my installation. I gonna try to
> install 1.3.0 somwehere. say, what Python are you using ?
>

OK, I use meld to diff my copy of ma/core.py with the latest trunk version.
There are lots of differences :) So there is a possibility that I might have
built my local numpy before 09/08. I should renew my copy. Do you know the
link of svn browser for the numpy? I don't know how you are making separate
installations without overriding other package? I either use Sage (if I have
extra time) or SPD. They are both shipped with numpy 1.3.0.

Let see how it will result with a new build...



> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
Gökhan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20091006/d92fd0c3/attachment.html>


More information about the NumPy-Discussion mailing list