Thanks. I just saw that maskedarray.putmask was gone and reached for
the nearest thing. I'll update this to what you suggest.
Mike
Eric Firing wrote:
> md...@us... wrote:
>> Revision: 7016
>>
>> http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7016&view=rev
>> Author: mdboom
>> Date: 2009年03月31日 15:22:06 +0000 (2009年3月31日)
>>
>
> ...
>
>> Modified: branches/v0_98_5_maint/lib/matplotlib/transforms.py
>> ===================================================================
>> --- branches/v0_98_5_maint/lib/matplotlib/transforms.py 2009年03月31日
>> 15:13:24 UTC (rev 7015)
>> +++ branches/v0_98_5_maint/lib/matplotlib/transforms.py 2009年03月31日
>> 15:22:06 UTC (rev 7016)
>> @@ -975,8 +975,7 @@
>> if self._invalid:
>> points = self._transform.transform(self._bbox.get_points())
>> if ma.isMaskedArray(points):
>> - points.putmask(0.0)
>> - points = np.asarray(points)
>> + np.putmask(points, points.mask, 0.0)
>> self._points = points
>> self._invalid = 0
>> return self._points
>
> Mike,
>
> A cleaner version is this:
>
> points = points.filled(0.0)
>
> Or you can replace the conditional and the assignment with the single
> line:
>
> points = np.ma.filled(points, 0.0)
>
> Example:
>
> In [6]:np.ma.filled([1,2,3], 0.0)
> Out[6]:array([1, 2, 3])
>
> In [7]:np.ma.filled(np.ma.array([1,2,3], mask=[False,True,False]), 0.0)
> Out[7]:array([1, 0, 3])
>
> The version you have actually can fail:
>
> In [10]:zz = np.ma.ones(5)
>
> In [11]:zz
> Out[11]:
> masked_array(data = [ 1. 1. 1. 1. 1.],
> mask = False,
> fill_value = 1e+20)
>
>
> In [12]:np.putmask(zz, zz.mask, 0)
> ---------------------------------------------------------------------------
>
> ValueError Traceback (most recent call
> last)
>
> /home/efiring/<ipython console> in <module>()
>
> ValueError: putmask: mask and data must be the same size
>
>
>
> Eric
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA