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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Apr 29 09:49:38 PDT 2016


4 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/ee5dcfbad0f3/
Changeset:   ee5dcfbad0f3
Branch:      yt
User:        atmyers
Date:        2016-04-28 20:48:36+00:00
Summary:     print an error message if the requested vectors are aligned.
Affected #:  1 file

diff -r b02a8c47c9d06013580dba4e5d559a5974d37ccb -r ee5dcfbad0f3a3d1632cc835b5cadf29229924c2 yt/utilities/orientation.py
--- a/yt/utilities/orientation.py
+++ b/yt/utilities/orientation.py
@@ -20,6 +20,29 @@
 from yt.units.yt_array import YTArray
 
 
+def _aligned(a, b):    
+    dot_product = np.abs(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b))
+    return np.isclose(dot_product, 1.0, 1.0e-13)
+    
+
+def _validate_unit_vectors(normal_vector, north_vector):
+
+    # Make sure vectors are unitless
+    if north_vector is not None:
+        north_vector = YTArray(north_vector, "", dtype='float64')
+    if normal_vector is not None:
+        normal_vector = YTArray(normal_vector, "", dtype='float64')
+
+    if not np.dot(normal_vector, normal_vector) > 0:
+        mylog.error("Normal vector is null")
+
+    if north_vector is not None and _aligned(north_vector, normal_vector):
+        mylog.error("North vector and normal vector are aligned.  Disregarding north vector.")
+        north_vector = None
+
+    return normal_vector, north_vector
+
+
 class Orientation(object):
     def __init__(self, normal_vector, north_vector=None, steady_north=False):
         r"""An object that returns a set of basis vectors for orienting
@@ -41,18 +64,9 @@
 
         """
 
-        # Make sure vectors are unitless
-        if north_vector is not None:
-            north_vector = YTArray(north_vector, "", dtype='float64')
-        if normal_vector is not None:
-            normal_vector = YTArray(normal_vector, "", dtype='float64')
-
+        normal_vector, north_vector = _validate_unit_vectors(normal_vector,
+                                                             north_vector)
         self.steady_north = steady_north
-        if not np.dot(normal_vector, normal_vector) > 0:
-            mylog.error("Normal vector is null")
-        if np.all(north_vector == normal_vector):
-            mylog.error("North vector and normal vector are the same.  Disregarding north vector.")
-            north_vector = None
         if north_vector is not None:
             self.steady_north = True
         self.north_vector = north_vector
@@ -61,15 +75,10 @@
             self.north_vector = self.unit_vectors[1]
 
     def _setup_normalized_vectors(self, normal_vector, north_vector):
+        normal_vector, north_vector = _validate_unit_vectors(normal_vector,
+                                                             north_vector)
         mylog.debug('Setting normalized vectors' + str(normal_vector)
                     + str(north_vector))
-
-        # Make sure vectors are unitless
-        if north_vector is not None:
-            north_vector = YTArray(north_vector, "", dtype='float64')
-        if normal_vector is not None:
-            normal_vector = YTArray(normal_vector, "", dtype='float64')
-
         # Now we set up our various vectors
         normal_vector /= np.sqrt(np.dot(normal_vector, normal_vector))
         if north_vector is None:


https://bitbucket.org/yt_analysis/yt/commits/ebecb1fea726/
Changeset:   ebecb1fea726
Branch:      yt
User:        atmyers
Date:        2016-04-28 21:00:18+00:00
Summary:     raise exception instead of logging and continuing.
Affected #:  1 file

diff -r ee5dcfbad0f3a3d1632cc835b5cadf29229924c2 -r ebecb1fea7261257179eea6845e71d556fda8a04 yt/utilities/orientation.py
--- a/yt/utilities/orientation.py
+++ b/yt/utilities/orientation.py
@@ -18,7 +18,7 @@
 
 from yt.funcs import mylog
 from yt.units.yt_array import YTArray
-
+from yt.utilities.exceptions import YTException
 
 def _aligned(a, b):    
     dot_product = np.abs(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b))
@@ -34,11 +34,10 @@
         normal_vector = YTArray(normal_vector, "", dtype='float64')
 
     if not np.dot(normal_vector, normal_vector) > 0:
-        mylog.error("Normal vector is null")
+        raise YTException("normal_vector cannot be the zero vector.")
 
     if north_vector is not None and _aligned(north_vector, normal_vector):
-        mylog.error("North vector and normal vector are aligned.  Disregarding north vector.")
-        north_vector = None
+        raise YTException("normal_vector and north_vector cannot be aligned.")
 
     return normal_vector, north_vector
 


https://bitbucket.org/yt_analysis/yt/commits/3d9c78c4ec94/
Changeset:   3d9c78c4ec94
Branch:      yt
User:        atmyers
Date:        2016-04-28 21:04:38+00:00
Summary:     less inaccurate variable name here.
Affected #:  1 file

diff -r ebecb1fea7261257179eea6845e71d556fda8a04 -r 3d9c78c4ec94660846ffbc11995e1afe45ef3771 yt/utilities/orientation.py
--- a/yt/utilities/orientation.py
+++ b/yt/utilities/orientation.py
@@ -20,9 +20,9 @@
 from yt.units.yt_array import YTArray
 from yt.utilities.exceptions import YTException
 
-def _aligned(a, b):    
-    dot_product = np.abs(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b))
-    return np.isclose(dot_product, 1.0, 1.0e-13)
+def _aligned(a, b):
+    aligned_component = np.abs(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b))
+    return np.isclose(aligned_component, 1.0, 1.0e-13)
     
 
 def _validate_unit_vectors(normal_vector, north_vector):


https://bitbucket.org/yt_analysis/yt/commits/0daf747c5d00/
Changeset:   0daf747c5d00
Branch:      yt
User:        xarthisius
Date:        2016-04-29 16:49:23+00:00
Summary:     Merged in atmyers/yt (pull request #2151)

Print an error message in Orientation if the requested vectors are aligned. Closes Issue #1189.
Affected #:  1 file

diff -r a3c2f4884d539e346255fbbb84117980d8d7719e -r 0daf747c5d006d087f132b62d750c61874a76e19 yt/utilities/orientation.py
--- a/yt/utilities/orientation.py
+++ b/yt/utilities/orientation.py
@@ -18,6 +18,28 @@
 
 from yt.funcs import mylog
 from yt.units.yt_array import YTArray
+from yt.utilities.exceptions import YTException
+
+def _aligned(a, b):
+    aligned_component = np.abs(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b))
+    return np.isclose(aligned_component, 1.0, 1.0e-13)
+    
+
+def _validate_unit_vectors(normal_vector, north_vector):
+
+    # Make sure vectors are unitless
+    if north_vector is not None:
+        north_vector = YTArray(north_vector, "", dtype='float64')
+    if normal_vector is not None:
+        normal_vector = YTArray(normal_vector, "", dtype='float64')
+
+    if not np.dot(normal_vector, normal_vector) > 0:
+        raise YTException("normal_vector cannot be the zero vector.")
+
+    if north_vector is not None and _aligned(north_vector, normal_vector):
+        raise YTException("normal_vector and north_vector cannot be aligned.")
+
+    return normal_vector, north_vector
 
 
 class Orientation(object):
@@ -41,18 +63,9 @@
 
         """
 
-        # Make sure vectors are unitless
-        if north_vector is not None:
-            north_vector = YTArray(north_vector, "", dtype='float64')
-        if normal_vector is not None:
-            normal_vector = YTArray(normal_vector, "", dtype='float64')
-
+        normal_vector, north_vector = _validate_unit_vectors(normal_vector,
+                                                             north_vector)
         self.steady_north = steady_north
-        if not np.dot(normal_vector, normal_vector) > 0:
-            mylog.error("Normal vector is null")
-        if np.all(north_vector == normal_vector):
-            mylog.error("North vector and normal vector are the same.  Disregarding north vector.")
-            north_vector = None
         if north_vector is not None:
             self.steady_north = True
         self.north_vector = north_vector
@@ -61,15 +74,10 @@
             self.north_vector = self.unit_vectors[1]
 
     def _setup_normalized_vectors(self, normal_vector, north_vector):
+        normal_vector, north_vector = _validate_unit_vectors(normal_vector,
+                                                             north_vector)
         mylog.debug('Setting normalized vectors' + str(normal_vector)
                     + str(north_vector))
-
-        # Make sure vectors are unitless
-        if north_vector is not None:
-            north_vector = YTArray(north_vector, "", dtype='float64')
-        if normal_vector is not None:
-            normal_vector = YTArray(normal_vector, "", dtype='float64')
-
         # Now we set up our various vectors
         normal_vector /= np.sqrt(np.dot(normal_vector, normal_vector))
         if north_vector is None:

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-svn-spacepope.org/attachments/20160429/a0051b5b/attachment.html>


More information about the yt-svn mailing list