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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Nov 25 10:14:15 PST 2013


7 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/1504cd455d94/
Changeset:   1504cd455d94
Branch:      yt
User:        ngoldbaum
Date:        2013-11-24 06:20:01
Summary:     [ProfilePlot] Only adjust the legend if it exists. Closes #731.
Affected #:  1 file

diff -r d2614f8a1367a0c184e52f6e7632a83741f07702 -r 1504cd455d94e23be8e5685679c8c08edd3cc3f4 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -197,7 +197,7 @@
         
         self.label = label
         if not isinstance(self.label, list):
-            self.label = [self.label] * len(self.profiles)
+            self.label = dict((p, label) for p in self.profiles)
 
         self.plot_spec = plot_spec
         if self.plot_spec is None:
@@ -295,7 +295,7 @@
         for i, profile in enumerate(self.profiles):
             for field, field_data in profile.field_data.items():
                 self.axes[field].plot(profile.x[:-1], field_data, 
-                                      label=self.label[i],
+                                      label=self.label[profile],
                                       **self.plot_spec[i])
         
         # This relies on 'profile' leaking
@@ -306,7 +306,8 @@
             axes.set_yscale(yscale)
             axes.set_xlabel(xtitle)
             axes.set_ylabel(ytitle)
-            axes.legend(loc="best")
+            if self.label[profile] is not None:
+                axes.legend(loc="best")
         self._plot_valid = True
 
     @classmethod


https://bitbucket.org/yt_analysis/yt/commits/88f1878ce4ce/
Changeset:   88f1878ce4ce
Branch:      yt
User:        ngoldbaum
Date:        2013-11-24 10:05:15
Summary:     [ProfilePlot] clean up logic, do input sanitization for label.
Affected #:  1 file

diff -r 1504cd455d94e23be8e5685679c8c08edd3cc3f4 -r 88f1878ce4ce392457da46e48f7dcc9863ede543 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -195,9 +195,16 @@
         else:
             self.profiles = ensure_list(profiles)
         
-        self.label = label
-        if not isinstance(self.label, list):
-            self.label = dict((p, label) for p in self.profiles)
+        label = ensure_list(label)
+        if len(label) != len(self.profiles):
+            raise RuntimeError(
+                "Number of labels must match number of profiles")
+
+        if any((not isinstance(l, basestring) for l in label)
+            raise RuntimeError(
+                "All labels must be strings")
+
+        self.label = dict((p, l) for p,l in zip(self.profiles, label))
 
         self.plot_spec = plot_spec
         if self.plot_spec is None:


https://bitbucket.org/yt_analysis/yt/commits/33908976063d/
Changeset:   33908976063d
Branch:      yt
User:        ngoldbaum
Date:        2013-11-24 10:39:24
Summary:     [ProfilePlotter] fixing a syntax error.
Affected #:  1 file

diff -r 88f1878ce4ce392457da46e48f7dcc9863ede543 -r 33908976063d0016cf6c3e918521cefab44d25e2 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -200,7 +200,7 @@
             raise RuntimeError(
                 "Number of labels must match number of profiles")
 
-        if any((not isinstance(l, basestring) for l in label)
+        if any((not isinstance(l, basestring) for l in label)):
             raise RuntimeError(
                 "All labels must be strings")
 


https://bitbucket.org/yt_analysis/yt/commits/16726e038cff/
Changeset:   16726e038cff
Branch:      yt
User:        ngoldbaum
Date:        2013-11-24 19:10:20
Summary:     Backed out changeset 33908976063d
Affected #:  1 file

diff -r 33908976063d0016cf6c3e918521cefab44d25e2 -r 16726e038cffd8ad2a5108a8e029d596fcb420fb yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -200,7 +200,7 @@
             raise RuntimeError(
                 "Number of labels must match number of profiles")
 
-        if any((not isinstance(l, basestring) for l in label)):
+        if any((not isinstance(l, basestring) for l in label)
             raise RuntimeError(
                 "All labels must be strings")
 


https://bitbucket.org/yt_analysis/yt/commits/78d5e0d61a1b/
Changeset:   78d5e0d61a1b
Branch:      yt
User:        ngoldbaum
Date:        2013-11-24 19:10:59
Summary:     Backed out 88f1878ce4ce
Affected #:  1 file

diff -r 16726e038cffd8ad2a5108a8e029d596fcb420fb -r 78d5e0d61a1be223c1332449336a4249c1d852b0 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -195,16 +195,9 @@
         else:
             self.profiles = ensure_list(profiles)
         
-        label = ensure_list(label)
-        if len(label) != len(self.profiles):
-            raise RuntimeError(
-                "Number of labels must match number of profiles")
-
-        if any((not isinstance(l, basestring) for l in label)
-            raise RuntimeError(
-                "All labels must be strings")
-
-        self.label = dict((p, l) for p,l in zip(self.profiles, label))
+        self.label = label
+        if not isinstance(self.label, list):
+            self.label = dict((p, label) for p in self.profiles)
 
         self.plot_spec = plot_spec
         if self.plot_spec is None:


https://bitbucket.org/yt_analysis/yt/commits/a5610ee7f06b/
Changeset:   a5610ee7f06b
Branch:      yt
User:        ngoldbaum
Date:        2013-11-24 19:11:19
Summary:     backed out 1504cd455d94
Affected #:  1 file

diff -r 78d5e0d61a1be223c1332449336a4249c1d852b0 -r a5610ee7f06bd42bede6cb89350bce4d3f49e5a0 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -197,7 +197,7 @@
         
         self.label = label
         if not isinstance(self.label, list):
-            self.label = dict((p, label) for p in self.profiles)
+            self.label = [self.label] * len(self.profiles)
 
         self.plot_spec = plot_spec
         if self.plot_spec is None:
@@ -295,7 +295,7 @@
         for i, profile in enumerate(self.profiles):
             for field, field_data in profile.field_data.items():
                 self.axes[field].plot(profile.x[:-1], field_data, 
-                                      label=self.label[profile],
+                                      label=self.label[i],
                                       **self.plot_spec[i])
         
         # This relies on 'profile' leaking
@@ -306,8 +306,7 @@
             axes.set_yscale(yscale)
             axes.set_xlabel(xtitle)
             axes.set_ylabel(ytitle)
-            if self.label[profile] is not None:
-                axes.legend(loc="best")
+            axes.legend(loc="best")
         self._plot_valid = True
 
     @classmethod


https://bitbucket.org/yt_analysis/yt/commits/cf9629f33e72/
Changeset:   cf9629f33e72
Branch:      yt
User:        ngoldbaum
Date:        2013-11-24 19:23:32
Summary:     [ProfilePlot] Doing input sanitization on labels.  Leaving them as a list.
Affected #:  1 file

diff -r a5610ee7f06bd42bede6cb89350bce4d3f49e5a0 -r cf9629f33e7236f210eaae66050aed5759e69dc5 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -87,6 +87,21 @@
         self[key] = figure.add_subplot(111)
         return self[key]
 
+def sanitize_label(label, nprofiles):
+    label = ensure_list(label)
+    
+    if len(label) == 1:
+        label = label * nprofiles
+    
+    if len(label) != nprofiles:
+        raise RuntimeError("Number of labels must match number of profiles")
+
+    for l in label:
+        if l is not None and not isinstance(l, basestring):
+            raise RuntimeError("All labels must be None or a string")
+
+    return label
+
 class ProfilePlot(object):
     r"""
     Create a 1d profile plot from a data source or from a list 
@@ -195,9 +210,7 @@
         else:
             self.profiles = ensure_list(profiles)
         
-        self.label = label
-        if not isinstance(self.label, list):
-            self.label = [self.label] * len(self.profiles)
+        self.label = sanitize_label(label, len(self.profiles))
 
         self.plot_spec = plot_spec
         if self.plot_spec is None:
@@ -306,7 +319,8 @@
             axes.set_yscale(yscale)
             axes.set_xlabel(xtitle)
             axes.set_ylabel(ytitle)
-            axes.legend(loc="best")
+            if any(self.label):
+                axes.legend(loc="best")
         self._plot_valid = True
 
     @classmethod

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