[Numpy-discussion] Questions about masked arrays

Gökhan Sever gokhansever@gmail....
Wed Oct 7 00:12:19 CDT 2009


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

>
> On Oct 7, 2009, at 12:10 AM, Gökhan Sever wrote:
>
> > Created the ticket http://projects.scipy.org/numpy/ticket/1253
>
> Want even more confusion ?
>  >>> x = ma.array([1,2,3],mask=[0,1,0], dtype=int)
>  >>> x[0].dtype
> dtype('int64')
>  >>> x[1].dtype
> dtype('float64')
>  >>> x[2].dtype
> dtype('int64')
>
> Yet another illustration of the masked constant... The more I think
> about it, the more I think we should have a specific object
> ("MaskedConstant") that would do nothing but tell us that it is masked.
>

Confusing indeed.

One more from me:

I[1]: a = np.arange(5)

I[2]: mask = 999

I[6]: a[3] = 999

I[7]: am = ma.masked_equal(a, mask)

I[8]: am
O[8]:
masked_array(data = [0 1 2 -- 4],
             mask = [False False False  True False],
       fill_value = 999999)

Where does this fill_value come from? To me it is little confusing having a
"value" and "fill_value" in masked array method arguments.


>
>
> > Could you tell me briefly what was the source of leak in arccos case?
>
> No idea, as I still haven't figured why you were having the problem in
> the first place
>

Probably you can pin-point the error by testing a 1.3.0 version numpy. Not
too many arc function with masked array users around I guess :)


>
> > And how do you write a test code for these cases?
>
> assert(np.arccos(ma.masked), ma.masked) would be the simplest.
>

Good to know this. The more I spend time with numpy the more I understand
the importance of testing the code automatically. This said, I still find
the test-driven-development approach somewhat bizarre. Start only by writing
test code and keep implementing your code until all the tests are satisfied.
Very interesting...These software engineers...


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



-- 
Gökhan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20091007/3815d41c/attachment.html 


More information about the NumPy-Discussion mailing list