[Python-modules-commits] [python-mplexporter] 58/135: call all renderer.draw_* with explicit keywords

Wolfgang Borgert debacle at moszumanska.debian.org
Tue Sep 23 21:19:03 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to branch master
in repository python-mplexporter.

commit 63e1b17adf5325fb2a9321132dab51597e91890c
Author: Jake Vanderplas <vanderplas at astro.washington.edu>
Date:   Wed Feb 26 12:16:45 2014 -0800

    call all renderer.draw_* with explicit keywords
---
 mplexporter/exporter.py       | 53 +++++++++++++++++++++++--------------------
 mplexporter/renderers/base.py | 43 +++++++++++++++++++----------------
 2 files changed, 52 insertions(+), 44 deletions(-)

diff --git a/mplexporter/exporter.py b/mplexporter/exporter.py
index 94657d0..ffdcfa7 100644
--- a/mplexporter/exporter.py
+++ b/mplexporter/exporter.py
@@ -98,13 +98,15 @@ class Exporter(object):
 
     def crawl_fig(self, fig):
         """Crawl the figure and process all axes"""
-        with self.renderer.draw_figure(fig, utils.get_figure_properties(fig)):
+        with self.renderer.draw_figure(fig=fig,
+                                       props=utils.get_figure_properties(fig)):
             for ax in fig.axes:
                 self.crawl_ax(ax)
 
     def crawl_ax(self, ax):
         """Crawl the axes and process all elements within"""
-        with self.renderer.draw_axes(ax, utils.get_axes_properties(ax)):
+        with self.renderer.draw_axes(ax=ax,
+                                     props=utils.get_axes_properties(ax)):
             for line in ax.lines:
                 self.draw_line(ax, line)
             for text in ax.texts:
@@ -139,18 +141,18 @@ class Exporter(object):
 
     def draw_line(self, ax, line):
         """Process a matplotlib line and call renderer.draw_line"""
-        code, data = self.process_transform(line.get_transform(),
-                                            ax, line.get_xydata())
+        coordinates, data = self.process_transform(line.get_transform(),
+                                                    ax, line.get_xydata())
         linestyle = utils.get_line_style(line)
         if linestyle['dasharray'] not in ['None', 'none', None]:
-            self.renderer.draw_line(data,
-                                    coordinates=code,
+            self.renderer.draw_line(data=data,
+                                    coordinates=coordinates,
                                     style=linestyle, mplobj=line)
 
         markerstyle = utils.get_marker_style(line)
         if markerstyle['marker'] not in ['None', 'none', None]:
-            self.renderer.draw_markers(data,
-                                       coordinates=code,
+            self.renderer.draw_markers(data=data,
+                                       coordinates=coordinates,
                                        style=markerstyle, mplobj=line)
 
     def draw_text(self, ax, text):
@@ -159,11 +161,12 @@ class Exporter(object):
         if content:
             transform = text.get_transform()
             position = text.get_position()
-            code, position = self.process_transform(transform, ax,
-                                                    position)
+            coordinates, position = self.process_transform(transform, ax,
+                                                           position)
             style = utils.get_text_style(text)
-            self.renderer.draw_text(content, position, code,
-                                    style, mplobj=text)
+            self.renderer.draw_text(text=content, position=position,
+                                    coordinates=coordinates,
+                                    style=style, mplobj=text)
 
     def draw_patch(self, ax, patch):
         """Process a matplotlib patch object and call renderer.draw_path"""
@@ -172,7 +175,7 @@ class Exporter(object):
         coordinates, vertices = self.process_transform(transform,
                                                        ax, vertices)
         linestyle = utils.get_path_style(patch, fill=patch.get_fill())
-        self.renderer.draw_path(vertices,
+        self.renderer.draw_path(data=vertices,
                                 coordinates=coordinates,
                                 pathcodes=pathcodes,
                                 style=linestyle,
@@ -183,13 +186,13 @@ class Exporter(object):
         (transform, transOffset,
          offsets, paths) = collection._prepare_points()
 
-        offset_coordinates, offsets = self.process_transform(transOffset,
-                                                             ax,
-                                                             offsets)
+        offset_coords, offsets = self.process_transform(transOffset,
+                                                        ax,
+                                                        offsets)
 
         processed_paths = [utils.SVG_path(path) for path in paths]
-        path_coordinates, tr = self.process_transform(transform, ax,
-                                                      return_trans=True)
+        path_coords, tr = self.process_transform(transform, ax,
+                                                 return_trans=True)
         processed_paths = [(tr.transform(path[0]), path[1])
                            for path in processed_paths]
         path_transforms = collection.get_transforms()
@@ -203,13 +206,13 @@ class Exporter(object):
                        "screen": "after"}
         offset_order = offset_dict[collection.get_offset_position()]
 
-        self.renderer.draw_path_collection(processed_paths,
-                                           path_coordinates,
-                                           path_transforms,
-                                           offsets,
-                                           offset_coordinates,
-                                           offset_order,
-                                           styles,
+        self.renderer.draw_path_collection(paths=processed_paths,
+                                           path_coordinates=path_coords,
+                                           path_transforms=path_transforms,
+                                           offsets=offsets,
+                                           offset_coordinates=offset_coords,
+                                           offset_order=offset_order,
+                                           styles=styles,
                                            mplobj=collection)
 
     def draw_image(self, ax, image):
diff --git a/mplexporter/renderers/base.py b/mplexporter/renderers/base.py
index f562c36..828f3d2 100644
--- a/mplexporter/renderers/base.py
+++ b/mplexporter/renderers/base.py
@@ -34,32 +34,32 @@ class Renderer(object):
         return self.ax_has_ygrid(self._current_ax)
 
     @contextmanager
-    def draw_figure(self, fig, properties):
+    def draw_figure(self, fig, props):
         if hasattr(self, "_current_fig") and self._current_fig is not None:
             warnings.warn("figure embedded in figure: something is wrong")
         self._current_fig = fig
-        self._fig_properties = properties
-        self.open_figure(fig, properties)
+        self._fig_props = props
+        self.open_figure(fig=fig, props=props)
         yield
-        self.close_figure(fig)
+        self.close_figure(fig=fig)
         self._current_fig = None
-        self._fig_properties = {}
+        self._fig_props = {}
 
     @contextmanager
-    def draw_axes(self, ax, properties):
+    def draw_axes(self, ax, props):
         if hasattr(self, "_current_ax") and self._current_ax is not None:
             warnings.warn("axes embedded in axes: something is wrong")
         self._current_ax = ax
-        self._ax_properties = properties
-        self.open_axes(ax, properties)
+        self._ax_props = props
+        self.open_axes(ax=ax, props=props)
         yield
-        self.close_axes(ax)
+        self.close_axes(ax=ax)
         self._current_ax = None
-        self._ax_properties = {}
+        self._ax_props = {}
 
     # Following are the functions which should be overloaded in subclasses
 
-    def open_figure(self, fig, properties):
+    def open_figure(self, fig, props):
         """
         Begin commands for a particular figure.
 
@@ -67,7 +67,7 @@ class Renderer(object):
         ----------
         fig : matplotlib.Figure
             The Figure which will contain the ensuing axes and elements
-        properties : dictionary
+        props : dictionary
             The dictionary of figure properties
         """
         pass
@@ -83,7 +83,7 @@ class Renderer(object):
         """
         pass
 
-    def open_axes(self, ax, properties):
+    def open_axes(self, ax, props):
         """
         Begin commands for a particular axes.
 
@@ -91,7 +91,7 @@ class Renderer(object):
         ----------
         ax : matplotlib.Axes
             The Axes which will contain the ensuing axes and elements
-        properties : dictionary
+        props : dictionary
             The dictionary of axes properties
         """
         pass
@@ -132,7 +132,8 @@ class Renderer(object):
         pathstyle = dict(facecolor='none', **style)
         pathstyle['edgecolor'] = pathstyle.pop('color')
         pathstyle['edgewidth'] = pathstyle.pop('linewidth')
-        self.draw_path(data, coordinates, pathcodes, pathstyle, mplobj=mplobj)
+        self.draw_path(data=data, coordinates=coordinates,
+                       pathcodes=pathcodes, style=pathstyle, mplobj=mplobj)
 
     @staticmethod
     def _iter_path_collection(paths, path_transforms, offsets, styles):
@@ -216,8 +217,10 @@ class Renderer(object):
                      "dasharray": "10,0",
                      "alpha": styles['alpha'],
                      "zorder": styles['zorder']}
-            self.draw_path(vertices, path_coordinates, pathcodes, style,
-                           offset, offset_coordinates, mplobj=mplobj)
+            self.draw_path(data=vertices, coordinates=path_coordinates,
+                           pathcodes=pathcodes, style=style, offset=offset,
+                           offset_coordinates=offset_coordinates,
+                           mplobj=mplobj)
 
     def draw_markers(self, data, coordinates, style, mplobj=None):
         """
@@ -245,8 +248,10 @@ class Renderer(object):
                                                        'edgewidth'])
         pathstyle['dasharray'] = "10,0"
         for vertex in data:
-            self.draw_path(vertices, "points", pathcodes, pathstyle,
-                           vertex, coordinates, mplobj=mplobj)
+            self.draw_path(data=vertices, coordinates="points",
+                           pathcodes=pathcodes, style=pathstyle,
+                           offset=vertex, offset_coordinates=coordinates,
+                           mplobj=mplobj)
 
     def draw_text(self, text, position, coordinates, style, mplobj=None):
         """

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-mplexporter.git



More information about the Python-modules-commits mailing list