[Numpy-discussion] [SciPy-dev] SciPy Sprint results

Eric Firing efiring@hawaii....
Fri Dec 21 12:13:13 CST 2007


I think the description of the putmask difference is missing the point. 
  The real difference is not in the way the third argument is handled, 
or  its required shape, but in whether the mask is updated or not.

numpy.ma.putmask updates the mask; that is, if it "puts" something into 
the array in a formerly masked location, the mask at that location is 
changed to False.

maskedarray.putmask does *not* update the original mask; it does a 
ndarray putmask operation on only the *unmasked* values.

In [18]:import maskedarray as ma
In [19]:mask1 = [False, True, False]
In [21]:x = ma.array([1,2,3], mask=mask1)
In [22]:mask2 = [False, True, True]
In [23]:ma.putmask(x, mask2, 10)
In [24]:x
masked_array(data = [1 -- 10],
       mask = [False  True False],

In [25]:x = numpy.ma.array([1,2,3], mask=mask1)
In [26]:numpy.ma.putmask(x, mask2, 10)
In [27]:x
array(data =
  [ 1 10 10],
       mask =
  [False False False],

This is a fundamental difference.  The maskedarray (new) behavior 
perhaps is more consistent with the general pattern of differences 
between masked and unmasked array functions and methods.


Stefan van der Walt wrote:
> On Thu, Dec 20, 2007 at 06:52:38PM -0500, Pierre GM wrote:
>>> If we can document exactly what the compatibility issues are (and it
>>> looks like we are almost there), we should move forward.
>> OK, I'll take care of that this week-end. Stefan, feel free to beat me to 
>> it...
> A first draft is here:
> http://svn.scipy.org/svn/numpy/branches/maskedarray/numpy/ma/API_CHANGES.txt
> Regards
> Stéfan
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion

More information about the Numpy-discussion mailing list