<html><body>
<p>1 new commit in yt:</p>
<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-2ByeRZFC1LslHcg6aJmnQ70VruLbmeLQr27D2E25aTBaxbkjuF2bqmsYkWQ-2BUEwYW6LU13aavAP9bbq18GpRtv8Fy0BSi1PqkITITIYAXphLLOjvyjErZJngZazYsQ8vrT6i9iTD7lNWoWT-2Fue7OiOebmXl85G1uHzPL91YZv4hHfO0srJeZJbm3qPBKIbzsQMj-2FWYExh1-2FNnf2rwbUsiCrljxOD2fStH7CI-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>