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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Oct 22 18:34:35 PDT 2013


5 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/833159ff1610/
Changeset:   833159ff1610
Branch:      yt
User:        ngoldbaum
Date:        2013-10-21 08:24:16
Summary:     Do more input sanitization for set_center.  Closes #676
Affected #:  1 file

diff -r c2b8455b43a67b78aa01953daf000dcca10aa8cb -r 833159ff161001e122cd10e1a5ab01b26b94c279 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -532,7 +532,7 @@
 
         parameters
         ----------
-        new_center : two element sequence of floats
+        new_center : two or three element sequence of floats
             The coordinates of the new center of the image.
             If the unit keyword is not specified, the
             coordinates are assumed to be in code units
@@ -543,9 +543,21 @@
         """
         if new_center is None:
             self.center = None
-        else:
+        elif iterable(new_center):
+            if len(new_center) == 3:
+                try:
+                    axis_index = self.data_source.axis
+                    new_center = [new_center[x_dict[axis_index]],
+                                  new_center[y_dict[axis_index]]]
+                except AttributeError:
+                    #FIXME convert to off-axis coordinate system.
+                    raise RuntimeError("Must specify center in window "
+                                       "coordinates for off-axis plots.")
             new_center = [c / self.pf[unit] for c in new_center]
             self.center = new_center
+        else:
+            raise RuntimeError("set_center accepts a two or three-element "
+                               "list or tuple of floats.")
         self.set_window(self.bounds)
         return self
 


https://bitbucket.org/yt_analysis/yt/commits/1739911b36c9/
Changeset:   1739911b36c9
Branch:      yt
User:        ngoldbaum
Date:        2013-10-21 08:39:24
Summary:     A little bit more inut checking and documentation.
Affected #:  1 file

diff -r 833159ff161001e122cd10e1a5ab01b26b94c279 -r 1739911b36c915f7d0a86ceac6ec7909010d61cb yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -535,7 +535,9 @@
         new_center : two or three element sequence of floats
             The coordinates of the new center of the image.
             If the unit keyword is not specified, the
-            coordinates are assumed to be in code units
+            coordinates are assumed to be in code units.
+            new_center must be specified relative to the simulation
+            coordinate system.
 
         unit : string
             The name of the unit new_center is given in.
@@ -544,6 +546,9 @@
         if new_center is None:
             self.center = None
         elif iterable(new_center):
+            assert all(isinstance(el, Number) for el in new_center) \
+                and len(new_center) in (2,3), \
+                "new_center must be a list or tuple of floats"
             if len(new_center) == 3:
                 try:
                     axis_index = self.data_source.axis


https://bitbucket.org/yt_analysis/yt/commits/1fadceaa7011/
Changeset:   1fadceaa7011
Branch:      yt
User:        ngoldbaum
Date:        2013-10-23 01:00:56
Summary:     Updating set_center to not accept 3-tuples.  Improving error reporting.
Affected #:  1 file

diff -r 1739911b36c915f7d0a86ceac6ec7909010d61cb -r 1fadceaa7011a554a2d03ed64517428d51ab8080 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -532,37 +532,35 @@
 
         parameters
         ----------
-        new_center : two or three element sequence of floats
-            The coordinates of the new center of the image.
-            If the unit keyword is not specified, the
-            coordinates are assumed to be in code units.
-            new_center must be specified relative to the simulation
-            coordinate system.
+        new_center : two or element sequence of floats
+            The coordinates of the new center of the image in the
+            coordinate system defined by the plot axes. If the unit
+            keyword is not specified, the coordinates are assumed to
+            be in code units.
 
         unit : string
             The name of the unit new_center is given in.
 
         """
+        error = RuntimeError(
+            "\n"
+            "new_center must be a two-element list or tuple of floats \n"
+            "corresponding to a coordinate in the plot relative to \n"
+            "the plot coordinate system.\n"
+        )
         if new_center is None:
             self.center = None
         elif iterable(new_center):
-            assert all(isinstance(el, Number) for el in new_center) \
-                and len(new_center) in (2,3), \
-                "new_center must be a list or tuple of floats"
-            if len(new_center) == 3:
-                try:
-                    axis_index = self.data_source.axis
-                    new_center = [new_center[x_dict[axis_index]],
-                                  new_center[y_dict[axis_index]]]
-                except AttributeError:
-                    #FIXME convert to off-axis coordinate system.
-                    raise RuntimeError("Must specify center in window "
-                                       "coordinates for off-axis plots.")
+            try:
+                assert all(isinstance(el, Number) for el in new_center)
+            except AssertionError:
+                raise error
+            if len(new_center) != 2:
+                raise error
             new_center = [c / self.pf[unit] for c in new_center]
             self.center = new_center
         else:
-            raise RuntimeError("set_center accepts a two or three-element "
-                               "list or tuple of floats.")
+            raise error
         self.set_window(self.bounds)
         return self
 


https://bitbucket.org/yt_analysis/yt/commits/db8f55a2be0a/
Changeset:   db8f55a2be0a
Branch:      yt
User:        ngoldbaum
Date:        2013-10-23 01:03:26
Summary:     Fixing a typo.
Affected #:  1 file

diff -r 1fadceaa7011a554a2d03ed64517428d51ab8080 -r db8f55a2be0a6b07845df32dfbba1a9e7a6aaf8a yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -532,7 +532,7 @@
 
         parameters
         ----------
-        new_center : two or element sequence of floats
+        new_center : two element sequence of floats
             The coordinates of the new center of the image in the
             coordinate system defined by the plot axes. If the unit
             keyword is not specified, the coordinates are assumed to


https://bitbucket.org/yt_analysis/yt/commits/e4575d3f2e04/
Changeset:   e4575d3f2e04
Branch:      yt
User:        MatthewTurk
Date:        2013-10-23 03:34:32
Summary:     Merged in ngoldbaum/yt (pull request #618)

Do more input sanitization for set_center. Closes #676
Affected #:  1 file

diff -r 08984ce3671ebdf48ffde7f28cd1a658f0822df3 -r e4575d3f2e046376d422b8ae73f8050477536a1d yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -533,19 +533,34 @@
         parameters
         ----------
         new_center : two element sequence of floats
-            The coordinates of the new center of the image.
-            If the unit keyword is not specified, the
-            coordinates are assumed to be in code units
+            The coordinates of the new center of the image in the
+            coordinate system defined by the plot axes. If the unit
+            keyword is not specified, the coordinates are assumed to
+            be in code units.
 
         unit : string
             The name of the unit new_center is given in.
 
         """
+        error = RuntimeError(
+            "\n"
+            "new_center must be a two-element list or tuple of floats \n"
+            "corresponding to a coordinate in the plot relative to \n"
+            "the plot coordinate system.\n"
+        )
         if new_center is None:
             self.center = None
-        else:
+        elif iterable(new_center):
+            try:
+                assert all(isinstance(el, Number) for el in new_center)
+            except AssertionError:
+                raise error
+            if len(new_center) != 2:
+                raise error
             new_center = [c / self.pf[unit] for c in new_center]
             self.center = new_center
+        else:
+            raise error
         self.set_window(self.bounds)
         return self

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