[yt-svn] commit/yt-3.0: MatthewTurk: Adding check_field call to handle non-tuple field names. Fixes #530.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Mar 19 04:14:28 PDT 2013


1 new commit in yt-3.0:

https://bitbucket.org/yt_analysis/yt-3.0/commits/6f02ff4f88f0/
changeset:   6f02ff4f88f0
branch:      yt-3.0
user:        MatthewTurk
date:        2013-03-19 12:14:19
summary:     Adding check_field call to handle non-tuple field names.  Fixes #530.
affected #:  1 file

diff -r dba8e90381b5be3b028790fc00201cca02fd936c -r 6f02ff4f88f052c518cc7dc56623655784350403 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -595,7 +595,7 @@
             fields = self.plots.keys()
         else:
             fields = [field]
-        for field in fields:
+        for field in self._field_check(fields):
             if log:
                 self._field_transform[field] = log_transform
             else:
@@ -603,6 +603,7 @@
 
     @invalidate_plot
     def set_transform(self, field, name):
+        field = self._field_check(field)
         if name not in field_transforms: 
             raise KeyError(name)
         self._field_transform[field] = field_transforms[name]
@@ -621,11 +622,11 @@
 
         """
 
-        if field is 'all':
+        if field == 'all':
             fields = self.plots.keys()
         else:
             fields = [field]
-        for field in fields:
+        for field in self._field_check(fields):
             self._colorbar_valid = False
             self._colormaps[field] = cmap_name
 
@@ -659,7 +660,7 @@
             fields = self.plots.keys()
         else:
             fields = [field]
-        for field in fields:
+        for field in self._field_check(fields):
             myzmin = zmin
             myzmax = zmax
             if zmin == 'min':
@@ -773,7 +774,7 @@
     def get_field_units(self, field, strip_mathml = True):
         ds = self._frb.data_source
         pf = self.pf
-        field = self.data_source._determine_fields(field)[0]
+        field = self._check_field(field)
         finfo = self.data_source.pf._get_field_info(*field)
         if ds._type_name in ("slice", "cutting"):
             units = finfo.get_units()
@@ -788,6 +789,12 @@
             units = units.replace(r"\rm{", "").replace("}","")
         return units
 
+    def _field_check(self, field):
+        field = self.data_source._determine_fields(field)
+        if isinstance(field, (list, tuple)):
+            return field
+        else:
+            return field[0]
 
 class PWViewerMPL(PWViewer):
     """Viewer using matplotlib as a backend via the WindowPlotMPL. 
@@ -1011,7 +1018,7 @@
         else:
             fields = [field]
 
-        for field in fields:
+        for field in self._field_check(fields):
             self._colorbar_valid = False
             self._colormaps[field] = cmap
             if isinstance(cmap, types.StringTypes):
@@ -1678,7 +1685,7 @@
 
     @invalidate_data
     def set_current_field(self, field):
-        field = self.data_source._determine_fields(field)[0]
+        field = self._check_field(field)
         self._current_field = field
         self._frb[field]
         finfo = self.data_source.pf._get_field_info(*field)

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

--

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