[Numpy-discussion] [SciPy-dev] SciPy Sprint results
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 :import maskedarray as ma
In :mask1 = [False, True, False]
In :x = ma.array([1,2,3], mask=mask1)
In :mask2 = [False, True, True]
In :ma.putmask(x, mask2, 10)
masked_array(data = [1 -- 10],
mask = [False True False],
In :x = numpy.ma.array([1,2,3], mask=mask1)
In :numpy.ma.putmask(x, mask2, 10)
[ 1 10 10],
[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
> A first draft is here:
> Numpy-discussion mailing list
More information about the Numpy-discussion