> > Unfortunately if the value is changed to masked, this is not updated
> > in the parent array. This seems very inconsistent. I don't view masked
> > values any different than any other value.
>
> Inconsistent, maybe, useful definitely:
> Masking a view and getting the original masked accordingly
> With the new implementation, the data is not shared for any of the 3
> variations above.
The 'copy=True' in MaskedArray.__new__ ensures that data is always copied by
default (that's the way I liked it). Most methods that return new masked
arrays (__getitem__ and __setitem__, for example) do n
If I make some minor changes (below) to MaskedArray get and setitem
from numpyext.maskedarray import *
a = array([[1,2,3,4,5],[6,7,8,9,10]], mask=nomask)
suba = a[0]
suba[1] = masked
print a
>[[1 -- 3 4 5]
> [6 7 8 9 10]]
print suba
>[1 -- 3 4 5]
suba = a[1]
suba[1] = 10
print a
>[[1 -- 3 4 5]
>
Perhaps an example will help explain what I mean
For the case of an ndarray if you select a row and then alter the new
array, the old array
is also changed.
from numpy import *
a = array([[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5]])
suba = a[2]
suba[1] = 10
print a
print suba
--output--
[[ 1 2 3 4 5
On Tuesday 21 November 2006 21:11, Michael Sorich wrote:
> I think that the new implementation is making a copy of the data with
> indexing a MA. This is different from both ndarray and the existing
> numpy ma version.
Michael,
If you check the definition of MaskedArray.__new__, you'll see that t
I think that the new implementation is making a copy of the data with
indexing a MA. This is different from both ndarray and the existing
numpy ma version.
e.g.
testma = ma.array([[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5]], mask=ma.nomask)
testma2 = testma[1]
testma2[1] = 20
print testma
print testma2