From: <ef...@us...> - 2011-02-09 04:16:14
|
Revision: 8965 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8965&view=rev Author: efiring Date: 2011-02-09 04:16:08 +0000 (Wed, 09 Feb 2011) Log Message: ----------- Normalize: major speed-up via bypassing masked array division Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/colors.py Modified: trunk/matplotlib/lib/matplotlib/colors.py =================================================================== --- trunk/matplotlib/lib/matplotlib/colors.py 2011-02-08 13:27:16 UTC (rev 8964) +++ trunk/matplotlib/lib/matplotlib/colors.py 2011-02-09 04:16:08 UTC (rev 8965) @@ -853,8 +853,11 @@ mask = ma.getmask(result) result = ma.array(np.clip(result.filled(vmax), vmin, vmax), mask=mask) - result -= vmin - result /= vmax - vmin + # ma division is very slow; we can take a shortcut + resdat = result.data + resdat -= vmin + resdat /= (vmax - vmin) + result = np.ma.array(resdat, mask=result.mask, copy=False) if is_scalar: result = result[0] return result This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |