SourceForge logo
SourceForge logo
Menu

Re: [matplotlib-devel] SF.net SVN: matplotlib:[7016] branches/v0_98_5_maint/lib/matplotlib

From: Michael D. <md...@st...> - 2009年03月31日 17:47:38
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

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /