Revision: 6256
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6256&view=rev
Author: efiring
Date: 2008-10-18 19:51:22 +0000 (Sat, 18 Oct 2008)
Log Message:
-----------
Clip floating point values before conversion to integer; thanks to Tony Yu.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/colors.py
Modified: trunk/matplotlib/lib/matplotlib/colors.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/colors.py 2008-10-18 17:47:28 UTC (rev
6255)
+++ trunk/matplotlib/lib/matplotlib/colors.py 2008-10-18 19:51:22 UTC (rev
6256)
@@ -455,7 +455,10 @@
mask_bad = ma.getmask(xma)
if xa.dtype.char in np.typecodes['Float']:
np.putmask(xa, xa==1.0, 0.9999999) #Treat 1.0 as slightly less
than 1.
- xa = (xa * self.N).astype(int)
+ # The following clip is fast, and prevents possible
+ # conversion of large positive values to negative integers.
+ np.clip(xa * self.N, -1, self.N, out=xa)
+ xa = xa.astype(int)
# Set the over-range indices before the under-range;
# otherwise the under-range values get converted to over-range.
np.putmask(xa, xa>self.N-1, self._i_over)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins