[yt-svn] commit/yt: 10 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Jul 24 23:28:41 PDT 2013


10 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/a871c3ae20da/
Changeset:   a871c3ae20da
Branch:      yt
User:        ngoldbaum
Date:        2013-07-20 23:49:35
Summary:     Persisting the figure and axes if they've already been created.
Affected #:  2 files

diff -r e3e4f4578504b7eb2e929275ad8441ef3900572c -r a871c3ae20dafcfc363cf5eb8e4afebeed89bce3 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -33,12 +33,15 @@
     """A base class for all yt plots made using matplotlib.
 
     """
-    def __init__(self, fsize, axrect):
+    def __init__(self, fsize, axrect, figure, axes):
         """Initialize PlotMPL class"""
         self._plot_valid = True
-        self.figure = matplotlib.figure.Figure(figsize=fsize,
-                                               frameon=True)
-        self.axes = self.figure.add_axes(axrect)
+        if figure is None:
+            self.figure = matplotlib.figure.Figure(figsize=fsize, frameon=True)
+            self.axes = self.figure.add_axes(axrect)
+        else:
+            self.figure = figure
+            self.axes = axes
 
     def save(self, name, mpl_kwargs, canvas=None):
         """Choose backend and save image to disk"""
@@ -67,9 +70,9 @@
     """A base class for yt plots made using imshow
 
     """
-    def __init__(self, fsize, axrect, caxrect, zlim):
+    def __init__(self, fsize, axrect, caxrect, zlim, figure, axes):
         """Initialize ImagePlotMPL class object"""
-        PlotMPL.__init__(self, fsize, axrect)
+        PlotMPL.__init__(self, fsize, axrect, figure, axes)
         self.zmin, self.zmax = zlim
         self.cax = self.figure.add_axes(caxrect)
 

diff -r e3e4f4578504b7eb2e929275ad8441ef3900572c -r a871c3ae20dafcfc363cf5eb8e4afebeed89bce3 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -878,9 +878,15 @@
 
             fp = self._font_properties
 
+            fig = None
+            axes = None
+            if self.plots.has_key(f):
+                fig = self.plots[f].figure
+                axes = self.plots[f].axes
+
             self.plots[f] = WindowPlotMPL(image, self._field_transform[f].name,
                                           self._colormaps[f], extent, aspect,
-                                          zlim, size, fp.get_size())
+                                          zlim, size, fp.get_size(), fig, axes)
 
             axes_unit_labels = ['', '']
             for i, un in enumerate((unit_x, unit_y)):
@@ -1751,7 +1757,9 @@
             self._field_transform[field] = linear_transform
 
 class WindowPlotMPL(ImagePlotMPL):
-    def __init__(self, data, cbname, cmap, extent, aspect, zlim, size, fontsize):
+    def __init__(
+            self, data, cbname, cmap, extent, aspect, zlim, size, fontsize,
+            figure, axes):
         fsize, axrect, caxrect = self._get_best_layout(size, fontsize)
         if np.any(np.array(axrect) < 0):
             mylog.warning('The axis ratio of the requested plot is very narrow.  '
@@ -1760,7 +1768,7 @@
                           'and matplotlib.')
             axrect  = (0.07, 0.10, 0.80, 0.80)
             caxrect = (0.87, 0.10, 0.04, 0.80)
-        ImagePlotMPL.__init__(self, fsize, axrect, caxrect, zlim)
+        ImagePlotMPL.__init__(self, fsize, axrect, caxrect, zlim, figure, axes)
         self._init_image(data, cbname, cmap, extent, aspect)
         self.image.axes.ticklabel_format(scilimits=(-2,3))
         if cbname == 'linear':


https://bitbucket.org/yt_analysis/yt/commits/aafaf5e05853/
Changeset:   aafaf5e05853
Branch:      yt
User:        ngoldbaum
Date:        2013-07-21 00:28:34
Summary:     Only persist plots if the plot bounds are the same in plot coordinates.
Affected #:  1 file

diff -r a871c3ae20dafcfc363cf5eb8e4afebeed89bce3 -r aafaf5e058537af917624886e4bf10cf9de18fb7 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -881,8 +881,10 @@
             fig = None
             axes = None
             if self.plots.has_key(f):
-                fig = self.plots[f].figure
-                axes = self.plots[f].axes
+                if extent == list(self.plots[f].figure.axes[0].get_xlim() +
+                                  self.plots[f].figure.axes[0].get_ylim()):
+                    fig = self.plots[f].figure
+                    axes = self.plots[f].axes
 
             self.plots[f] = WindowPlotMPL(image, self._field_transform[f].name,
                                           self._colormaps[f], extent, aspect,


https://bitbucket.org/yt_analysis/yt/commits/d64966317aa5/
Changeset:   d64966317aa5
Branch:      yt
User:        ngoldbaum
Date:        2013-07-21 02:05:17
Summary:     Updates to fix failing answer tests.
Affected #:  2 files

diff -r aafaf5e058537af917624886e4bf10cf9de18fb7 -r d64966317aa572ce73ea06e2e06b565cd59d1d34 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -74,9 +74,11 @@
         """Initialize ImagePlotMPL class object"""
         PlotMPL.__init__(self, fsize, axrect, figure, axes)
         self.zmin, self.zmax = zlim
+        if figure is not None:
+            self.figure.delaxes(self.figure.axes[1])
         self.cax = self.figure.add_axes(caxrect)
 
-    def _init_image(self, data, cbnorm, cmap, extent, aspect=None):
+    def _init_image(self, data, cbnorm, cmap, extent, aspect):
         """Store output of imshow in image variable"""
         if (cbnorm == 'log10'):
             norm = matplotlib.colors.LogNorm()

diff -r aafaf5e058537af917624886e4bf10cf9de18fb7 -r d64966317aa572ce73ea06e2e06b565cd59d1d34 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -90,6 +90,16 @@
         return rv
     return newfunc
 
+def invalidate_figure(f):
+    @wraps(f)
+    def newfunc(*args, **kwargs):
+        rv = f(*args, **kwargs)
+        for field in args[0].fields:
+            args[0].plots[field].figure = None
+            args[0].plots[field].axes = None
+        return rv
+    return newfunc
+
 def invalidate_plot(f):
     @wraps(f)
     def newfunc(*args, **kwargs):
@@ -558,6 +568,7 @@
             self.buff_size = (size, size)
 
     @invalidate_plot
+    @invalidate_figure
     def set_window_size(self, size):
         """Sets a new window size for the plot
 
@@ -881,10 +892,11 @@
             fig = None
             axes = None
             if self.plots.has_key(f):
-                if extent == list(self.plots[f].figure.axes[0].get_xlim() +
-                                  self.plots[f].figure.axes[0].get_ylim()):
-                    fig = self.plots[f].figure
-                    axes = self.plots[f].axes
+                if self.plots[f].figure is not None:
+                    if extent == list(self.plots[f].figure.axes[0].get_xlim() +
+                                      self.plots[f].figure.axes[0].get_ylim()):
+                        fig = self.plots[f].figure
+                        axes = self.plots[f].axes
 
             self.plots[f] = WindowPlotMPL(image, self._field_transform[f].name,
                                           self._colormaps[f], extent, aspect,
@@ -955,6 +967,7 @@
                 del self._frb[key]
 
     @invalidate_plot
+    @invalidate_figure
     def set_font(self, font_dict=None):
         """set the font and font properties
 


https://bitbucket.org/yt_analysis/yt/commits/53372213b579/
Changeset:   53372213b579
Branch:      yt
User:        ngoldbaum
Date:        2013-07-21 02:05:32
Summary:     Adding a missing autogenerated c routine yt .hgignore.
Affected #:  1 file

diff -r d64966317aa572ce73ea06e2e06b565cd59d1d34 -r 53372213b5798fd605bcb39f4fdfa6c2fcf1b039 .hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -12,6 +12,7 @@
 yt/utilities/kdtree/forthonf2c.h
 yt/utilities/libconfig_wrapper.c
 yt/utilities/spatial/ckdtree.c
+yt/utilities/lib/amr_kdtools.c
 yt/utilities/lib/CICDeposit.c
 yt/utilities/lib/ContourFinding.c
 yt/utilities/lib/DepthFirstOctree.c


https://bitbucket.org/yt_analysis/yt/commits/47800a937ca8/
Changeset:   47800a937ca8
Branch:      yt
User:        ngoldbaum
Date:        2013-07-21 02:36:44
Summary:     One last fix for the failing answer tests.
Affected #:  1 file

diff -r 53372213b5798fd605bcb39f4fdfa6c2fcf1b039 -r 47800a937ca80f510f3456dca1ad97e31d6f87c3 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -41,6 +41,7 @@
             self.axes = self.figure.add_axes(axrect)
         else:
             self.figure = figure
+            axes.cla()
             self.axes = axes
 
     def save(self, name, mpl_kwargs, canvas=None):


https://bitbucket.org/yt_analysis/yt/commits/6f91fb293726/
Changeset:   6f91fb293726
Branch:      yt
User:        ngoldbaum
Date:        2013-07-21 02:52:36
Summary:     Only create a new figure if the aspect ratio changes.
Affected #:  1 file

diff -r 47800a937ca80f510f3456dca1ad97e31d6f87c3 -r 6f91fb293726757ee36a21dafdc5cd60bf45da5c yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -893,8 +893,10 @@
             axes = None
             if self.plots.has_key(f):
                 if self.plots[f].figure is not None:
-                    if extent == list(self.plots[f].figure.axes[0].get_xlim() +
-                                      self.plots[f].figure.axes[0].get_ylim()):
+                    oe = list(self.plots[f].figure.axes[0].get_xlim() +
+                              self.plots[f].figure.axes[0].get_ylim())
+                    if (oe[1] - oe[0]) / (oe[3] - oe[2]) == \
+                       (extent[1] - extent[0]) / (extent[3] - extent[2]):
                         fig = self.plots[f].figure
                         axes = self.plots[f].axes
 


https://bitbucket.org/yt_analysis/yt/commits/2777bdca59ab/
Changeset:   2777bdca59ab
Branch:      yt
User:        ngoldbaum
Date:        2013-07-21 21:56:10
Summary:     Setting the default canvas a bit earlier.  This makes animations easier.
Affected #:  1 file

diff -r 6f91fb293726757ee36a21dafdc5cd60bf45da5c -r 2777bdca59abb3e8a15a64d4c22a4a482c5a0191 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -39,6 +39,7 @@
         if figure is None:
             self.figure = matplotlib.figure.Figure(figsize=fsize, frameon=True)
             self.axes = self.figure.add_axes(axrect)
+            self.canvas = FigureCanvasAgg(self.figure)
         else:
             self.figure = figure
             axes.cla()
@@ -61,7 +62,7 @@
             canvas = FigureCanvasPS(self.figure)
         else:
             mylog.warning("Unknown suffix %s, defaulting to Agg", suffix)
-            canvas = FigureCanvasAgg(self.figure)
+            canvas = self.canvas
 
         canvas.print_figure(name, **mpl_kwargs)
         return name


https://bitbucket.org/yt_analysis/yt/commits/335b1c181f8e/
Changeset:   335b1c181f8e
Branch:      yt
User:        ngoldbaum
Date:        2013-07-21 22:05:23
Summary:     Setting the canvas outside a conditional to avoid doing it twice.
Affected #:  1 file

diff -r 2777bdca59abb3e8a15a64d4c22a4a482c5a0191 -r 335b1c181f8e62d4dab32d89db46e8f8feb084be yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -39,11 +39,11 @@
         if figure is None:
             self.figure = matplotlib.figure.Figure(figsize=fsize, frameon=True)
             self.axes = self.figure.add_axes(axrect)
-            self.canvas = FigureCanvasAgg(self.figure)
         else:
             self.figure = figure
             axes.cla()
             self.axes = axes
+        self.canvas = FigureCanvasAgg(self.figure)
 
     def save(self, name, mpl_kwargs, canvas=None):
         """Choose backend and save image to disk"""


https://bitbucket.org/yt_analysis/yt/commits/683e4ea8530e/
Changeset:   683e4ea8530e
Branch:      yt
User:        ngoldbaum
Date:        2013-07-22 06:46:53
Summary:     Simplifying things.  Treating colorbar axes just like the image other axes.
Affected #:  2 files

diff -r 335b1c181f8e62d4dab32d89db46e8f8feb084be -r 683e4ea8530e74b19b830301d067f7479feaaeec yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -38,9 +38,12 @@
         self._plot_valid = True
         if figure is None:
             self.figure = matplotlib.figure.Figure(figsize=fsize, frameon=True)
+        else:
+            figure.set_size_inches(fsize)
+            self.figure = figure
+        if axes is None:
             self.axes = self.figure.add_axes(axrect)
         else:
-            self.figure = figure
             axes.cla()
             self.axes = axes
         self.canvas = FigureCanvasAgg(self.figure)
@@ -72,13 +75,16 @@
     """A base class for yt plots made using imshow
 
     """
-    def __init__(self, fsize, axrect, caxrect, zlim, figure, axes):
+    def __init__(self, fsize, axrect, caxrect, zlim, figure, axes, cax):
         """Initialize ImagePlotMPL class object"""
         PlotMPL.__init__(self, fsize, axrect, figure, axes)
         self.zmin, self.zmax = zlim
-        if figure is not None:
-            self.figure.delaxes(self.figure.axes[1])
-        self.cax = self.figure.add_axes(caxrect)
+        if cax is None:
+            self.cax = self.figure.add_axes(caxrect)
+        else:
+            cax.cla()
+            cax.set_position(caxrect)
+            self.cax = cax
 
     def _init_image(self, data, cbnorm, cmap, extent, aspect):
         """Store output of imshow in image variable"""

diff -r 335b1c181f8e62d4dab32d89db46e8f8feb084be -r 683e4ea8530e74b19b830301d067f7479feaaeec yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -97,6 +97,7 @@
         for field in args[0].fields:
             args[0].plots[field].figure = None
             args[0].plots[field].axes = None
+            args[0].plots[field].cax = None
         return rv
     return newfunc
 
@@ -891,18 +892,17 @@
 
             fig = None
             axes = None
+            cax = None
             if self.plots.has_key(f):
                 if self.plots[f].figure is not None:
-                    oe = list(self.plots[f].figure.axes[0].get_xlim() +
-                              self.plots[f].figure.axes[0].get_ylim())
-                    if (oe[1] - oe[0]) / (oe[3] - oe[2]) == \
-                       (extent[1] - extent[0]) / (extent[3] - extent[2]):
-                        fig = self.plots[f].figure
-                        axes = self.plots[f].axes
+                    fig = self.plots[f].figure
+                    axes = self.plots[f].axes
+                    cax = self.plots[f].cax
 
             self.plots[f] = WindowPlotMPL(image, self._field_transform[f].name,
                                           self._colormaps[f], extent, aspect,
-                                          zlim, size, fp.get_size(), fig, axes)
+                                          zlim, size, fp.get_size(), fig, axes,
+                                          cax)
 
             axes_unit_labels = ['', '']
             for i, un in enumerate((unit_x, unit_y)):
@@ -1776,7 +1776,7 @@
 class WindowPlotMPL(ImagePlotMPL):
     def __init__(
             self, data, cbname, cmap, extent, aspect, zlim, size, fontsize,
-            figure, axes):
+            figure, axes, cax):
         fsize, axrect, caxrect = self._get_best_layout(size, fontsize)
         if np.any(np.array(axrect) < 0):
             mylog.warning('The axis ratio of the requested plot is very narrow.  '
@@ -1785,7 +1785,8 @@
                           'and matplotlib.')
             axrect  = (0.07, 0.10, 0.80, 0.80)
             caxrect = (0.87, 0.10, 0.04, 0.80)
-        ImagePlotMPL.__init__(self, fsize, axrect, caxrect, zlim, figure, axes)
+        ImagePlotMPL.__init__(
+            self, fsize, axrect, caxrect, zlim, figure, axes, cax)
         self._init_image(data, cbname, cmap, extent, aspect)
         self.image.axes.ticklabel_format(scilimits=(-2,3))
         if cbname == 'linear':


https://bitbucket.org/yt_analysis/yt/commits/0fa3092155e5/
Changeset:   0fa3092155e5
Branch:      yt
User:        xarthisius
Date:        2013-07-25 08:28:35
Summary:     Merged in ngoldbaum/yt (pull request #556)

Persist matplotlib figure and axes as PlotWindow plots are modified.
Affected #:  3 files

diff -r 30d7d50462133455ee81d6dec3f7da5b37c5c31e -r 0fa3092155e585ba80513dd8f153d70186f2b67f .hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -12,6 +12,7 @@
 yt/utilities/kdtree/forthonf2c.h
 yt/utilities/libconfig_wrapper.c
 yt/utilities/spatial/ckdtree.c
+yt/utilities/lib/amr_kdtools.c
 yt/utilities/lib/CICDeposit.c
 yt/utilities/lib/ContourFinding.c
 yt/utilities/lib/DepthFirstOctree.c

diff -r 30d7d50462133455ee81d6dec3f7da5b37c5c31e -r 0fa3092155e585ba80513dd8f153d70186f2b67f yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -33,12 +33,20 @@
     """A base class for all yt plots made using matplotlib.
 
     """
-    def __init__(self, fsize, axrect):
+    def __init__(self, fsize, axrect, figure, axes):
         """Initialize PlotMPL class"""
         self._plot_valid = True
-        self.figure = matplotlib.figure.Figure(figsize=fsize,
-                                               frameon=True)
-        self.axes = self.figure.add_axes(axrect)
+        if figure is None:
+            self.figure = matplotlib.figure.Figure(figsize=fsize, frameon=True)
+        else:
+            figure.set_size_inches(fsize)
+            self.figure = figure
+        if axes is None:
+            self.axes = self.figure.add_axes(axrect)
+        else:
+            axes.cla()
+            self.axes = axes
+        self.canvas = FigureCanvasAgg(self.figure)
 
     def save(self, name, mpl_kwargs, canvas=None):
         """Choose backend and save image to disk"""
@@ -57,7 +65,7 @@
             canvas = FigureCanvasPS(self.figure)
         else:
             mylog.warning("Unknown suffix %s, defaulting to Agg", suffix)
-            canvas = FigureCanvasAgg(self.figure)
+            canvas = self.canvas
 
         canvas.print_figure(name, **mpl_kwargs)
         return name
@@ -67,13 +75,18 @@
     """A base class for yt plots made using imshow
 
     """
-    def __init__(self, fsize, axrect, caxrect, zlim):
+    def __init__(self, fsize, axrect, caxrect, zlim, figure, axes, cax):
         """Initialize ImagePlotMPL class object"""
-        PlotMPL.__init__(self, fsize, axrect)
+        PlotMPL.__init__(self, fsize, axrect, figure, axes)
         self.zmin, self.zmax = zlim
-        self.cax = self.figure.add_axes(caxrect)
+        if cax is None:
+            self.cax = self.figure.add_axes(caxrect)
+        else:
+            cax.cla()
+            cax.set_position(caxrect)
+            self.cax = cax
 
-    def _init_image(self, data, cbnorm, cmap, extent, aspect=None):
+    def _init_image(self, data, cbnorm, cmap, extent, aspect):
         """Store output of imshow in image variable"""
         if (cbnorm == 'log10'):
             norm = matplotlib.colors.LogNorm()

diff -r 30d7d50462133455ee81d6dec3f7da5b37c5c31e -r 0fa3092155e585ba80513dd8f153d70186f2b67f yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -90,6 +90,17 @@
         return rv
     return newfunc
 
+def invalidate_figure(f):
+    @wraps(f)
+    def newfunc(*args, **kwargs):
+        rv = f(*args, **kwargs)
+        for field in args[0].fields:
+            args[0].plots[field].figure = None
+            args[0].plots[field].axes = None
+            args[0].plots[field].cax = None
+        return rv
+    return newfunc
+
 def invalidate_plot(f):
     @wraps(f)
     def newfunc(*args, **kwargs):
@@ -558,6 +569,7 @@
             self.buff_size = (size, size)
 
     @invalidate_plot
+    @invalidate_figure
     def set_window_size(self, size):
         """Sets a new window size for the plot
 
@@ -878,9 +890,19 @@
 
             fp = self._font_properties
 
+            fig = None
+            axes = None
+            cax = None
+            if self.plots.has_key(f):
+                if self.plots[f].figure is not None:
+                    fig = self.plots[f].figure
+                    axes = self.plots[f].axes
+                    cax = self.plots[f].cax
+
             self.plots[f] = WindowPlotMPL(image, self._field_transform[f].name,
                                           self._colormaps[f], extent, aspect,
-                                          zlim, size, fp.get_size())
+                                          zlim, size, fp.get_size(), fig, axes,
+                                          cax)
 
             axes_unit_labels = ['', '']
             for i, un in enumerate((unit_x, unit_y)):
@@ -947,6 +969,7 @@
                 del self._frb[key]
 
     @invalidate_plot
+    @invalidate_figure
     def set_font(self, font_dict=None):
         """set the font and font properties
 
@@ -1748,7 +1771,9 @@
             self._field_transform[field] = linear_transform
 
 class WindowPlotMPL(ImagePlotMPL):
-    def __init__(self, data, cbname, cmap, extent, aspect, zlim, size, fontsize):
+    def __init__(
+            self, data, cbname, cmap, extent, aspect, zlim, size, fontsize,
+            figure, axes, cax):
         fsize, axrect, caxrect = self._get_best_layout(size, fontsize)
         if np.any(np.array(axrect) < 0):
             mylog.warning('The axis ratio of the requested plot is very narrow.  '
@@ -1757,7 +1782,8 @@
                           'and matplotlib.')
             axrect  = (0.07, 0.10, 0.80, 0.80)
             caxrect = (0.87, 0.10, 0.04, 0.80)
-        ImagePlotMPL.__init__(self, fsize, axrect, caxrect, zlim)
+        ImagePlotMPL.__init__(
+            self, fsize, axrect, caxrect, zlim, figure, axes, cax)
         self._init_image(data, cbname, cmap, extent, aspect)
         self.image.axes.ticklabel_format(scilimits=(-2,3))
         if cbname == 'linear':

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list