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

Eric Firing efiring at hawaii.edu
Fri Dec 21 13:13:13 EST 2007


Stefan,

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
Out[24]:
masked_array(data = [1 -- 10],
       mask = [False  True False],
       fill_value=999999)

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


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.

Eric

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 at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion




More information about the NumPy-Discussion mailing list