[Numpy-discussion] masked arrays as array indices

Ernest Adrogué eadrogue@gmx....
Mon Sep 21 11:05:19 CDT 2009


Hello there,

Given a masked array such as this one:

In [19]: x = np.ma.masked_equal([-1, -1, 0, -1, 2], -1)

In [20]: x
Out[20]: 
masked_array(data = [-- -- 0 -- 2],
             mask = [ True  True False  True False],
       fill_value = 999999)

When you make an assignemnt in the vein of x[x == 0] = 25
the result can be a bit puzzling:

In [21]: x[x == 0] = 25

In [22]: x
Out[22]: 
masked_array(data = [25 25 25 25 2],
             mask = [False False False False False],
       fill_value = 999999)

Is this the correct result or have I found a bug?

Cheers.

-- 
Ernest


More information about the NumPy-Discussion mailing list