<html><body>
<p>6 new commits in yt:</p>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/aeb657a4f10e/">https://bitbucket.org/yt_analysis/yt/commits/aeb657a4f10e/</a> Changeset:   aeb657a4f10e Branch:      yt User:        ngoldbaum Date:        2016-05-17 02:01:45+00:00 Summary:     [opt] performance improvement for YTArray addition Affected #:  2 files</p>
<p>diff -r 06b1bf872faa352183a5f8ec91d72937b9c43523 -r aeb657a4f10e24c8565c8b2e2b6f0a46efd2c421 yt/units/unit_object.py --- a/yt/units/unit_object.py +++ b/yt/units/unit_object.py @@ -389,6 +389,9 @@</p>
<pre>def same_dimensions_as(self, other_unit):
    """ Test if dimensions are the same. """</pre>
<p>+        # test first for ‘is’ equality to avoid expensive sympy operation +        if self.dimensions is other_unit.dimensions: +            return True</p>
<pre>        return (self.dimensions / other_unit.dimensions) == sympy_one

    @property</pre>
<p>diff -r 06b1bf872faa352183a5f8ec91d72937b9c43523 -r aeb657a4f10e24c8565c8b2e2b6f0a46efd2c421 yt/units/yt_array.py --- a/yt/units/yt_array.py +++ b/yt/units/yt_array.py @@ -526,8 +526,7 @@</p>
<pre>        new_units = self._unit_repr_check_same(units)
        (conversion_factor, offset) = self.units.get_conversion_factor(new_units)
</pre>
<ul><li><p>new_array = self * conversion_factor</p></li>
<li><p>new_array.units = new_units</p></li></ul>
<p>+        new_array = type(self)(self.value * conversion_factor, new_units)</p>
<pre>         if offset:
np.subtract(new_array, offset*new_array.uq, new_array)</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/3d078499006c/">https://bitbucket.org/yt_analysis/yt/commits/3d078499006c/</a> Changeset:   3d078499006c Branch:      yt User:        ngoldbaum Date:        2016-05-17 14:56:25+00:00 Summary:     refactor so _unit_repr_check_same is not a member function Affected #:  1 file</p>
<p>diff -r aeb657a4f10e24c8565c8b2e2b6f0a46efd2c421 -r 3d078499006ccfb35edf40f8af56786d22da217c yt/units/yt_array.py --- a/yt/units/yt_array.py +++ b/yt/units/yt_array.py @@ -174,6 +174,30 @@</p>
<pre>    return other
</pre>
<p>+def _unit_repr_check_same(my_units, other_units): +    """ +    Takes a Unit object, or string of known unit symbol, and check that it +    is compatible with this quantity. Returns Unit object. + +    """ +    # let Unit() handle units arg if it's not already a Unit obj. +    if not isinstance(other_units, Unit): +        other_units = Unit(other_units, registry=my_units.registry) + +    equiv_dims = em_dimensions.get(my_units.dimensions, None) +    if equiv_dims == other_units.dimensions: +        if current_mks in equiv_dims.free_symbols: +            base = “SI” +        else: +            base = “CGS” +        raise YTEquivalentDimsError(my_units, other_units, base) + +    if not my_units.same_dimensions_as(other_units): +        raise YTUnitConversionError( +            my_units, my_units.dimensions, other_units, other_units.dimensions) + +    return other_units +</p>
<pre>unary_operators = (
    negative, absolute, rint, ones_like, sign, conj, exp, exp2, log, log2,
    log10, expm1, log1p, sqrt, square, reciprocal, sin, cos, tan, arcsin,</pre>
<p>@@ -430,30 +454,6 @@</p>
<pre>    # Start unit conversion methods
    #
</pre>
<ul><li><p>def _unit_repr_check_same(self, units):</p></li>
<li><p>"""</p></li>
<li><p>Takes a Unit object, or string of known unit symbol, and check that it</p></li>
<li><p>is compatible with this quantity. Returns Unit object.</p></li></ul>
<p>–</p>
<ul><li><p>"""</p></li>
<li><p># let Unit() handle units arg if it's not already a Unit obj.</p></li>
<li><p>if not isinstance(units, Unit):</p></li>
<li><p>units = Unit(units, registry=self.units.registry)</p></li></ul>
<p>–</p>
<ul><li><p>equiv_dims = em_dimensions.get(self.units.dimensions,None)</p></li>
<li><p>if equiv_dims == units.dimensions:</p></li>
<li><p>if current_mks in equiv_dims.free_symbols:</p></li>
<li><p>base = “SI”</p></li>
<li><p>else:</p></li>
<li><p>base = “CGS”</p></li>
<li><p>raise YTEquivalentDimsError(self.units, units, base)</p></li></ul>
<p>–</p>
<ul><li><p>if not self.units.same_dimensions_as(units):</p></li>
<li><p>raise YTUnitConversionError(</p></li>
<li><p>self.units, self.units.dimensions, units, units.dimensions)</p></li></ul>
<p>–</p>
<ul><li><p>return units</p></li></ul>
<p>–</p>
<pre>def convert_to_units(self, units):
    """
    Convert the array and units to the given units.</pre>
<p>@@ -464,7 +464,7 @@</p>
<pre>            The units you want to convert to.

        """</pre>
<ul><li><p>new_units = self._unit_repr_check_same(units)</p></li></ul>
<p>+        new_units = _unit_repr_check_same(self.units, units)</p>
<pre>        (conversion_factor, offset) = self.units.get_conversion_factor(new_units)

        self.units = new_units</pre>
<p>@@ -523,7 +523,7 @@</p>
<pre>        YTArray

        """</pre>
<ul><li><p>new_units = self._unit_repr_check_same(units)</p></li></ul>
<p>+        new_units = _unit_repr_check_same(self.units, units)</p>
<pre>        (conversion_factor, offset) = self.units.get_conversion_factor(new_units)

        new_array = type(self)(self.value * conversion_factor, new_units)</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/2764e1874862/">https://bitbucket.org/yt_analysis/yt/commits/2764e1874862/</a> Changeset:   2764e1874862 Branch:      yt User:        ngoldbaum Date:        2016-05-17 14:57:23+00:00 Summary:     decorate _unit_repr_check_same with an LRU cache Affected #:  1 file</p>
<p>diff -r 3d078499006ccfb35edf40f8af56786d22da217c -r 2764e1874862750e6d72e6a865bbe02b621ea02e yt/units/yt_array.py --- a/yt/units/yt_array.py +++ b/yt/units/yt_array.py @@ -174,6 +174,7 @@</p>
<pre>    return other
</pre>
<p>+@lru_cache(maxsize=128, typed=False)</p>
<pre>def _unit_repr_check_same(my_units, other_units):
    """
    Takes a Unit object, or string of known unit symbol, and check that it</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/6956889c0a1e/">https://bitbucket.org/yt_analysis/yt/commits/6956889c0a1e/</a> Changeset:   6956889c0a1e Branch:      yt User:        ngoldbaum Date:        2016-05-17 15:17:29+00:00 Summary:     optimize Unit.__ne__ to sometimes avoid sympy comparisons Affected #:  1 file</p>
<p>diff -r 2764e1874862750e6d72e6a865bbe02b621ea02e -r 6956889c0a1eea6a95bffa4f13ca9d7ec80c334f yt/units/unit_object.py --- a/yt/units/unit_object.py +++ b/yt/units/unit_object.py @@ -366,8 +366,12 @@</p>
<pre>         """ Test unit inequality. """
         if not isinstance(u, Unit):
return True</pre>
<ul><li><p>return \</p></li>
<li><p>(self.base_value != u.base_value or self.dimensions != u.dimensions)</p></li></ul>
<p>+        if self.base_value != u.base_value: +            return True +        # use ‘is’ comparison dimensions to avoid expensive sympy operation +        if self.dimensions is u.dimensions: +            return False +        return self.dimensions != u.dimensions</p>
<pre>def copy(self):
    return copy.deepcopy(self)</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/fa1066ce57a8/">https://bitbucket.org/yt_analysis/yt/commits/fa1066ce57a8/</a> Changeset:   fa1066ce57a8 Branch:      yt User:        ngoldbaum Date:        2016-05-17 23:45:10+00:00 Summary:     use a view to avoid copying in addition Affected #:  1 file</p>
<p>diff -r 6956889c0a1eea6a95bffa4f13ca9d7ec80c334f -r fa1066ce57a878a16810149c9edbd98e4f8e8e96 yt/units/yt_array.py --- a/yt/units/yt_array.py +++ b/yt/units/yt_array.py @@ -527,7 +527,7 @@</p>
<pre>        new_units = _unit_repr_check_same(self.units, units)
        (conversion_factor, offset) = self.units.get_conversion_factor(new_units)
</pre>
<ul><li><p>new_array = type(self)(self.value * conversion_factor, new_units)</p></li></ul>
<p>+        new_array = type(self)(self.ndview * conversion_factor, new_units)</p>
<pre>         if offset:
np.subtract(new_array, offset*new_array.uq, new_array)</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/de4aaa4344b2/">https://bitbucket.org/yt_analysis/yt/commits/de4aaa4344b2/</a> Changeset:   de4aaa4344b2 Branch:      yt User:        jzuhone Date:        2016-05-18 18:28:56+00:00 Summary:     Merged in ngoldbaum/yt (pull request #2179)</p>
<p>[opt] performance improvement for YTArray addition Affected #:  2 files</p>
<p>diff -r d39510be50625c14c6ee0ecb2d0195ff72a76dd8 -r de4aaa4344b2ffd78d9e4411074b9b398f5e6ad4 yt/units/unit_object.py --- a/yt/units/unit_object.py +++ b/yt/units/unit_object.py @@ -366,8 +366,12 @@</p>
<pre>         """ Test unit inequality. """
         if not isinstance(u, Unit):
return True</pre>
<ul><li><p>return \</p></li>
<li><p>(self.base_value != u.base_value or self.dimensions != u.dimensions)</p></li></ul>
<p>+        if self.base_value != u.base_value: +            return True +        # use ‘is’ comparison dimensions to avoid expensive sympy operation +        if self.dimensions is u.dimensions: +            return False +        return self.dimensions != u.dimensions</p>
<pre>def copy(self):
    return copy.deepcopy(self)</pre>
<p>@@ -389,6 +393,9 @@</p>
<pre>def same_dimensions_as(self, other_unit):
    """ Test if dimensions are the same. """</pre>
<p>+        # test first for ‘is’ equality to avoid expensive sympy operation +        if self.dimensions is other_unit.dimensions: +            return True</p>
<pre>        return (self.dimensions / other_unit.dimensions) == sympy_one

    @property</pre>
<p>diff -r d39510be50625c14c6ee0ecb2d0195ff72a76dd8 -r de4aaa4344b2ffd78d9e4411074b9b398f5e6ad4 yt/units/yt_array.py --- a/yt/units/yt_array.py +++ b/yt/units/yt_array.py @@ -174,6 +174,31 @@</p>
<pre>    return other
</pre>
<p>+@lru_cache(maxsize=128, typed=False) +def _unit_repr_check_same(my_units, other_units): +    """ +    Takes a Unit object, or string of known unit symbol, and check that it +    is compatible with this quantity. Returns Unit object. + +    """ +    # let Unit() handle units arg if it's not already a Unit obj. +    if not isinstance(other_units, Unit): +        other_units = Unit(other_units, registry=my_units.registry) + +    equiv_dims = em_dimensions.get(my_units.dimensions, None) +    if equiv_dims == other_units.dimensions: +        if current_mks in equiv_dims.free_symbols: +            base = “SI” +        else: +            base = “CGS” +        raise YTEquivalentDimsError(my_units, other_units, base) + +    if not my_units.same_dimensions_as(other_units): +        raise YTUnitConversionError( +            my_units, my_units.dimensions, other_units, other_units.dimensions) + +    return other_units +</p>
<pre>unary_operators = (
    negative, absolute, rint, ones_like, sign, conj, exp, exp2, log, log2,
    log10, expm1, log1p, sqrt, square, reciprocal, sin, cos, tan, arcsin,</pre>
<p>@@ -430,30 +455,6 @@</p>
<pre>    # Start unit conversion methods
    #
</pre>
<ul><li><p>def _unit_repr_check_same(self, units):</p></li>
<li><p>"""</p></li>
<li><p>Takes a Unit object, or string of known unit symbol, and check that it</p></li>
<li><p>is compatible with this quantity. Returns Unit object.</p></li></ul>
<p>–</p>
<ul><li><p>"""</p></li>
<li><p># let Unit() handle units arg if it's not already a Unit obj.</p></li>
<li><p>if not isinstance(units, Unit):</p></li>
<li><p>units = Unit(units, registry=self.units.registry)</p></li></ul>
<p>–</p>
<ul><li><p>equiv_dims = em_dimensions.get(self.units.dimensions,None)</p></li>
<li><p>if equiv_dims == units.dimensions:</p></li>
<li><p>if current_mks in equiv_dims.free_symbols:</p></li>
<li><p>base = “SI”</p></li>
<li><p>else:</p></li>
<li><p>base = “CGS”</p></li>
<li><p>raise YTEquivalentDimsError(self.units, units, base)</p></li></ul>
<p>–</p>
<ul><li><p>if not self.units.same_dimensions_as(units):</p></li>
<li><p>raise YTUnitConversionError(</p></li>
<li><p>self.units, self.units.dimensions, units, units.dimensions)</p></li></ul>
<p>–</p>
<ul><li><p>return units</p></li></ul>
<p>–</p>
<pre>def convert_to_units(self, units):
    """
    Convert the array and units to the given units.</pre>
<p>@@ -464,7 +465,7 @@</p>
<pre>            The units you want to convert to.

        """</pre>
<ul><li><p>new_units = self._unit_repr_check_same(units)</p></li></ul>
<p>+        new_units = _unit_repr_check_same(self.units, units)</p>
<pre>        (conversion_factor, offset) = self.units.get_conversion_factor(new_units)

        self.units = new_units</pre>
<p>@@ -523,11 +524,10 @@</p>
<pre>        YTArray

        """</pre>
<ul><li><p>new_units = self._unit_repr_check_same(units)</p></li></ul>
<p>+        new_units = _unit_repr_check_same(self.units, units)</p>
<pre>        (conversion_factor, offset) = self.units.get_conversion_factor(new_units)
</pre>
<ul><li><p>new_array = self * conversion_factor</p></li>
<li><p>new_array.units = new_units</p></li></ul>
<p>+        new_array = type(self)(self.ndview * conversion_factor, new_units)</p>
<pre>         if offset:
np.subtract(new_array, offset*new_array.uq, new_array)</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-2ByeRZFC1LslHcg6aJmnQ70VruLbmeLQr27Bz8dJL5lt5JayzvwZmrYlXZS-2BfoD5jP-2FZRiJOFxfE3nkRB-2B7EaEr5BGz1MAi8AgJPHlIRtjrcsFYEB9byeE0Wm5TecUvildjXDQBZcRGx0Tsu-2BWG52FgK0Hjoij6uORnNo5Qn8y-2BZfTtbb9Av-2FMwhygvmwBizgmlYz8LGajFO0ebAoS02ZeFnjY3itmKhk02Q-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>