[Numpy-discussion] Strange behavior in setting masked array values in Numpy 1.1.0

Matthieu Brucher matthieu.brucher@gmail....
Sat May 31 17:04:54 CDT 2008


Hi,

This is to be expected. You are trying to modify and read the same array at
the same time, which should never be done.

Matthieu

2008/5/31 Tony Yu <tsyu80@gmail.com>:

> Great job getting numpy 1.1.0 out and thanks for including the old API
> of masked arrays.
>
> I've been playing around with some software using numpy 1.0.4 and took
> a crack at upgrading it to numpy 1.1.0, but I ran into some strange
> behavior when assigning to slices of a masked array.
>
> I made the simplest example I could think of to show this weird
> behavior. Basically, reordering the masked array and assigning back to
> itself *on the same line* seems to work for part of the array, but
> other parts are left unchanged. In the example below, half of the
> array is assigned "properly" and the other half isn't. This problem is
> eliminated if the assignment is done with a copy of the array.
> Alternatively, this problem is eliminated if I using
> numpy.oldnumeric.ma.masked_array instead of the new masked array
> implementation.
>
> Is this just a problem on my setup?
>
> Thanks in advance for your help.
> -Tony Yu
>
> Example:
> ========
> In [1]: import numpy
>
> In [2]: masked = numpy.ma.masked_array([[1, 2, 3, 4, 5]], mask=False)
>
> In [3]: masked[:] = numpy.fliplr(masked.copy())
>
> In [4]: print masked
> [[5 4 3 2 1]]
>
> In [5]: masked[:] = numpy.fliplr(masked)
>
> In [6]: print masked
> [[1 2 3 2 1]]
>
>
> Specs:
> ======
> Numpy 1.1.0
> Python 2.5.1
> OS X Leopard 10.5.3
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080601/857f2c51/attachment.html 


More information about the Numpy-discussion mailing list