Revision: 6350
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6350&view=rev
Author: mdboom
Date: 2008-10-29 18:27:05 +0000 (Wed, 29 Oct 2008)
Log Message:
-----------
Speed up quadmesh drawing.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/collections.py
trunk/matplotlib/lib/matplotlib/path.py
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py 2008-10-29 18:26:34 UTC
(rev 6349)
+++ trunk/matplotlib/lib/matplotlib/collections.py 2008-10-29 18:27:05 UTC
(rev 6350)
@@ -551,12 +551,6 @@
else:
c = coordinates
- # We could let the Path constructor generate the codes for us,
- # but this is faster, since we know they'll always be the same
- codes = np.array(
- [Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO,
Path.CLOSEPOLY],
- Path.code_type)
-
points = np.concatenate((
c[0:-1, 0:-1],
c[0:-1, 1: ],
@@ -565,7 +559,7 @@
c[0:-1, 0:-1]
), axis=2)
points = points.reshape((meshWidth * meshHeight, 5, 2))
- return [Path(x, codes) for x in points]
+ return [Path(x) for x in points]
convert_mesh_to_paths = staticmethod(convert_mesh_to_paths)
def get_datalim(self, transData):
Modified: trunk/matplotlib/lib/matplotlib/path.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/path.py 2008-10-29 18:26:34 UTC (rev
6349)
+++ trunk/matplotlib/lib/matplotlib/path.py 2008-10-29 18:27:05 UTC (rev
6350)
@@ -111,6 +111,7 @@
self.should_simplify = (len(vertices) >= 128 and
(codes is None or np.all(codes <=
Path.LINETO)))
+ self.has_nonfinite = not np.isfinite(vertices).all()
self.codes = codes
self.vertices = vertices
@@ -183,13 +184,18 @@
for v in vertices[1:]:
yield v, LINETO
elif codes is None:
- next_code = MOVETO
- for v in vertices:
- if (~isfinite(v)).any():
- next_code = MOVETO
- else:
- yield v, next_code
- next_code = LINETO
+ if self.has_nonfinite:
+ next_code = MOVETO
+ for v in vertices:
+ if np.isfinite(v).all():
+ yield v, next_code
+ next_code = LINETO
+ else:
+ next_code = MOVETO
+ else:
+ yield vertices[0], MOVETO
+ for v in vertices[1:]:
+ yield v, LINETO
else:
i = 0
was_nan = False
@@ -203,7 +209,7 @@
else:
num_vertices = NUM_VERTICES[int(code)]
curr_vertices = vertices[i:i+num_vertices].flatten()
- if (~isfinite(curr_vertices)).any():
+ if not isfinite(curr_vertices).all():
was_nan = True
elif was_nan:
yield curr_vertices[-2:], MOVETO
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