<html><body>
<p>4 new commits in yt:</p>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/ee5dcfbad0f3/">https://bitbucket.org/yt_analysis/yt/commits/ee5dcfbad0f3/</a> 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</p>
<p>diff -r b02a8c47c9d06013580dba4e5d559a5974d37ccb -r ee5dcfbad0f3a3d1632cc835b5cadf29229924c2 yt/utilities/orientation.py --- a/yt/utilities/orientation.py +++ b/yt/utilities/orientation.py @@ -20,6 +20,29 @@</p>
<pre>from yt.units.yt_array import YTArray
</pre>
<p>+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 + +</p>
<pre>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</pre>
<p>@@ -41,18 +64,9 @@</p>
<pre> """
</pre>
<ul><li><p># Make sure vectors are unitless</p></li>
<li><p>if north_vector is not None:</p></li>
<li><p>north_vector = YTArray(north_vector, "", dtype='float64')</p></li>
<li><p>if normal_vector is not None:</p></li>
<li><p>normal_vector = YTArray(normal_vector, "", dtype='float64')</p></li></ul>
<p>– + normal_vector, north_vector = _validate_unit_vectors(normal_vector, + north_vector)</p>
<pre>self.steady_north = steady_north</pre>
<ul><li><p>if not np.dot(normal_vector, normal_vector) > 0:</p></li>
<li><p>mylog.error("Normal vector is null")</p></li>
<li><p>if np.all(north_vector == normal_vector):</p></li>
<li><p>mylog.error("North vector and normal vector are the same. Disregarding north vector.")</p></li>
<li><p>north_vector = None</p></li></ul>
<pre> if north_vector is not None:
self.steady_north = True
self.north_vector = north_vector</pre>
<p>@@ -61,15 +75,10 @@</p>
<pre> self.north_vector = self.unit_vectors[1]
def _setup_normalized_vectors(self, normal_vector, north_vector):</pre>
<p>+ normal_vector, north_vector = _validate_unit_vectors(normal_vector, + north_vector)</p>
<pre> mylog.debug('Setting normalized vectors' + str(normal_vector)
+ str(north_vector))</pre>
<p>–</p>
<ul><li><p># Make sure vectors are unitless</p></li>
<li><p>if north_vector is not None:</p></li>
<li><p>north_vector = YTArray(north_vector, "", dtype='float64')</p></li>
<li><p>if normal_vector is not None:</p></li>
<li><p>normal_vector = YTArray(normal_vector, "", dtype='float64')</p></li></ul>
<p>–</p>
<pre># Now we set up our various vectors
normal_vector /= np.sqrt(np.dot(normal_vector, normal_vector))
if north_vector is None:</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/ebecb1fea726/">https://bitbucket.org/yt_analysis/yt/commits/ebecb1fea726/</a> 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</p>
<p>diff -r ee5dcfbad0f3a3d1632cc835b5cadf29229924c2 -r ebecb1fea7261257179eea6845e71d556fda8a04 yt/utilities/orientation.py --- a/yt/utilities/orientation.py +++ b/yt/utilities/orientation.py @@ -18,7 +18,7 @@</p>
<pre>from yt.funcs import mylog
from yt.units.yt_array import YTArray</pre>
<p>– +from yt.utilities.exceptions import YTException</p>
<pre>def _aligned(a, b):
dot_product = np.abs(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b))</pre>
<p>@@ -34,11 +34,10 @@</p>
<pre> normal_vector = YTArray(normal_vector, "", dtype='float64')
if not np.dot(normal_vector, normal_vector) > 0:</pre>
<ul><li><p>mylog.error("Normal vector is null")</p></li></ul>
<p>+ raise YTException("normal_vector cannot be the zero vector.")</p>
<pre>if north_vector is not None and _aligned(north_vector, normal_vector):</pre>
<ul><li><p>mylog.error("North vector and normal vector are aligned. Disregarding north vector.")</p></li>
<li><p>north_vector = None</p></li></ul>
<p>+ raise YTException("normal_vector and north_vector cannot be aligned.")</p>
<pre> return normal_vector, north_vector
</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/3d9c78c4ec94/">https://bitbucket.org/yt_analysis/yt/commits/3d9c78c4ec94/</a> Changeset: 3d9c78c4ec94 Branch: yt User: atmyers Date: 2016-04-28 21:04:38+00:00 Summary: less inaccurate variable name here. Affected #: 1 file</p>
<p>diff -r ebecb1fea7261257179eea6845e71d556fda8a04 -r 3d9c78c4ec94660846ffbc11995e1afe45ef3771 yt/utilities/orientation.py --- a/yt/utilities/orientation.py +++ b/yt/utilities/orientation.py @@ -20,9 +20,9 @@</p>
<pre>from yt.units.yt_array import YTArray
from yt.utilities.exceptions import YTException
</pre>
<p>-def _aligned(a, b):</p>
<ul><li><p>dot_product = np.abs(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b))</p></li>
<li><p>return np.isclose(dot_product, 1.0, 1.0e-13)</p></li></ul>
<p>+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)</p>
<pre>def _validate_unit_vectors(normal_vector, north_vector):</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/0daf747c5d00/">https://bitbucket.org/yt_analysis/yt/commits/0daf747c5d00/</a> Changeset: 0daf747c5d00 Branch: yt User: xarthisius Date: 2016-04-29 16:49:23+00:00 Summary: Merged in atmyers/yt (pull request #2151)</p>
<p>Print an error message in Orientation if the requested vectors are aligned. Closes Issue #1189. Affected #: 1 file</p>
<p>diff -r a3c2f4884d539e346255fbbb84117980d8d7719e -r 0daf747c5d006d087f132b62d750c61874a76e19 yt/utilities/orientation.py --- a/yt/utilities/orientation.py +++ b/yt/utilities/orientation.py @@ -18,6 +18,28 @@</p>
<pre>from yt.funcs import mylog
from yt.units.yt_array import YTArray</pre>
<p>+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</p>
<pre>class Orientation(object):</pre>
<p>@@ -41,18 +63,9 @@</p>
<pre> """
</pre>
<ul><li><p># Make sure vectors are unitless</p></li>
<li><p>if north_vector is not None:</p></li>
<li><p>north_vector = YTArray(north_vector, "", dtype='float64')</p></li>
<li><p>if normal_vector is not None:</p></li>
<li><p>normal_vector = YTArray(normal_vector, "", dtype='float64')</p></li></ul>
<p>– + normal_vector, north_vector = _validate_unit_vectors(normal_vector, + north_vector)</p>
<pre>self.steady_north = steady_north</pre>
<ul><li><p>if not np.dot(normal_vector, normal_vector) > 0:</p></li>
<li><p>mylog.error("Normal vector is null")</p></li>
<li><p>if np.all(north_vector == normal_vector):</p></li>
<li><p>mylog.error("North vector and normal vector are the same. Disregarding north vector.")</p></li>
<li><p>north_vector = None</p></li></ul>
<pre> if north_vector is not None:
self.steady_north = True
self.north_vector = north_vector</pre>
<p>@@ -61,15 +74,10 @@</p>
<pre> self.north_vector = self.unit_vectors[1]
def _setup_normalized_vectors(self, normal_vector, north_vector):</pre>
<p>+ normal_vector, north_vector = _validate_unit_vectors(normal_vector, + north_vector)</p>
<pre> mylog.debug('Setting normalized vectors' + str(normal_vector)
+ str(north_vector))</pre>
<p>–</p>
<ul><li><p># Make sure vectors are unitless</p></li>
<li><p>if north_vector is not None:</p></li>
<li><p>north_vector = YTArray(north_vector, "", dtype='float64')</p></li>
<li><p>if normal_vector is not None:</p></li>
<li><p>normal_vector = YTArray(normal_vector, "", dtype='float64')</p></li></ul>
<p>–</p>
<pre># Now we set up our various vectors
normal_vector /= np.sqrt(np.dot(normal_vector, normal_vector))
if north_vector is None:</pre>
<p>Repository URL: <a href="https://bitbucket.org/yt_analysis/yt/">https://bitbucket.org/yt_analysis/yt/</a></p>
<p>—</p>
<p>This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.</p>
<img src="http://link.bitbucket.org/wf/open?upn=ll4ctv0L-2ByeRZFC1LslHcg6aJmnQ70VruLbmeLQr27DANIEFz5oGZS9OZYC40FfaMFG-2BJ-2B7GxgS5-2FO3sJmJD04UFxKAHST8HDVjfgA1qtXyM6rQrLauMp2pC2svCaZa33Gt7J9S-2Bdi0Ykq7LAvYetaUU2Gnjtapb1BBD8umFto0xhPgIpBsWHphbm3a0MacGNhEhlklI-2BWJWQXfVuCHVLJlHW7O3ROOEsiNBzu-2Bgv4k-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;"/>
</body></html>