[yt-svn] commit/yt: xarthisius: Merged in ngoldbaum/yt (pull request #1328)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Dec 9 11:22:04 PST 2014


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/4ce155015ea9/
Changeset:   4ce155015ea9
Branch:      yt
User:        xarthisius
Date:        2014-12-09 19:21:52+00:00
Summary:     Merged in ngoldbaum/yt (pull request #1328)

Delay running callbacks until the plot needs to be finalized. Closes #945
Affected #:  2 files

diff -r 8ad3ae533a5c38f97a234f7c55fb8afb9cdc8c61 -r 4ce155015ea95a99e4c6d2c805b0db6536bdc6f3 yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -35,6 +35,12 @@
 from yt.utilities.exceptions import \
     YTNotInsideNotebook
 
+def ensure_callbacks(f):
+    @wraps(f)
+    def newfunc(*args, **kwargs):
+        args[0].run_callbacks()
+        return f(*args, **kwargs)
+    return newfunc
 
 def invalidate_data(f):
     @wraps(f)
@@ -416,16 +422,17 @@
     def __getitem__(self, item):
         return self.plots[item]
 
-    def run_callbacks(self, f):
-        keys = self.frb.keys()
-        for name, (args, kwargs) in self._callbacks:
-            cbw = CallbackWrapper(self, self.plots[f], self.frb, f)
-            CallbackMaker = callback_registry[name]
-            callback = CallbackMaker(*args[1:], **kwargs)
-            callback(cbw)
-        for key in self.frb.keys():
-            if key not in keys:
-                del self.frb[key]
+    def run_callbacks(self):
+        for f in self.fields:
+            keys = self.frb.keys()
+            for name, (args, kwargs) in self._callbacks:
+                cbw = CallbackWrapper(self, self.plots[f], self.frb, f)
+                CallbackMaker = callback_registry[name]
+                callback = CallbackMaker(*args[1:], **kwargs)
+                callback(cbw)
+            for key in self.frb.keys():
+                if key not in keys:
+                    del self.frb[key]
 
     def _set_font_properties(self):
         for f in self.plots:
@@ -524,6 +531,7 @@
         self.figure_size = float(size)
         return self
 
+    @ensure_callbacks
     def save(self, name=None, mpl_kwargs=None):
         """saves the plot to disk.
 
@@ -629,6 +637,7 @@
         except YTNotInsideNotebook:
             return self.save(name=name, mpl_kwargs=mpl_kwargs)
 
+    @ensure_callbacks
     def _repr_html_(self):
         """Return an html representation of the plot object. Will display as a
         png for each WindowPlotMPL instance in self.plots"""

diff -r 8ad3ae533a5c38f97a234f7c55fb8afb9cdc8c61 -r 4ce155015ea95a99e4c6d2c805b0db6536bdc6f3 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -895,8 +895,6 @@
             else:
                 self.plots[f].cax.minorticks_off()
 
-            self.run_callbacks(f)
-
             if draw_axes is False:
                 self.plots[f]._toggle_axes(draw_axes)

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