[yt-svn] commit/yt: MatthewTurk: Catching the new fields that get added during a callback and removing them from
Bitbucket
commits-noreply at bitbucket.org
Thu Jul 12 08:13:55 PDT 2012
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/changeset/ff732c1ef7c7/
changeset: ff732c1ef7c7
branch: yt
user: MatthewTurk
date: 2012-07-12 14:47:55
summary: Catching the new fields that get added during a callback and removing them from
an FRB.
affected #: 2 files
diff -r 24e51f7495c082380d1ee2c575bf23651d791f38 -r ff732c1ef7c74f24c5ade73692a19d6ad8ca14f3 yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -113,10 +113,16 @@
self._period = (DD[xax], DD[yax])
self._edges = ( (DLE[xax], DRE[xax]), (DLE[yax], DRE[yax]) )
+ def keys(self):
+ return self.data.keys()
+
+ def __delitem__(self, item):
+ del self.data[item]
+
def __getitem__(self, item):
if item in self.data: return self.data[item]
- mylog.info("Making a fixed resolution buffer of %d by %d" % \
- (self.buff_size[0], self.buff_size[1]))
+ mylog.info("Making a fixed resolution buffer of (%s) %d by %d" % \
+ (item, self.buff_size[0], self.buff_size[1]))
buff = _MPL.Pixelize(self.data_source['px'],
self.data_source['py'],
self.data_source['pdx'],
diff -r 24e51f7495c082380d1ee2c575bf23651d791f38 -r ff732c1ef7c74f24c5ade73692a19d6ad8ca14f3 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -304,6 +304,7 @@
_colorbar_valid = False
_contour_info = None
_vector_info = None
+ _frb = None
def __init__(self, data_source, bounds, buff_size=(800,800), antialias = True,
periodic = True, origin='center-window', oblique=False):
r"""
@@ -354,6 +355,9 @@
return self.plots[item]
def _recreate_frb(self):
+ old_fields = None
+ if self._frb is not None:
+ old_fields = self._frb.keys()
try:
bounds = self.bounds
if self.oblique == False:
@@ -366,7 +370,10 @@
self.antialias, periodic=self._periodic)
except:
raise RuntimeError("Failed to repixelize.")
- self._frb._get_data_source_fields()
+ if old_fields is None:
+ self._frb._get_data_source_fields()
+ else:
+ for key in old_fields: self._frb[key]
self.pf = self._frb.pf
self._data_valid = True
@@ -629,7 +636,7 @@
if self._current_field is not None:
fields = [self._current_field]
else:
- fields = self._frb.data.keys()
+ fields = self._frb.keys()
self._colorbar_valid = True
for f in self.fields:
md = self.get_metadata(f, strip_mathml = False, return_string = False)
@@ -670,14 +677,21 @@
cb.set_label(r'$\rm{'+f.encode('string-escape')+r'}\/\/('+md['units']+r')$')
- for name,(args,kwargs) in self._callbacks:
- cbw = CallbackWrapper(self, self.plots[f], self._frb, f)
- CallbackMaker = getattr(CallbackMod,name)
- callback = CallbackMaker(*args[1:],**kwargs)
- callback(cbw)
+ self.run_callbacks(f)
self._plot_valid = True
+ 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 = getattr(CallbackMod, name)
+ callback = CallbackMaker(*args[1:], **kwargs)
+ callback(cbw)
+ for key in self._frb.keys():
+ if key not in keys:
+ del self._frb[key]
+
@invalidate_plot
def set_cmap(self, field, cmap):
if isinstance(cmap, types.StringTypes):
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