[yt-svn] commit/yt: jzuhone: Merged in ngoldbaum/yt (pull request #1686)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Aug 11 08:19:15 PDT 2015


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/87b696c1a0e3/
Changeset:   87b696c1a0e3
Branch:      yt
User:        jzuhone
Date:        2015-08-11 15:19:01+00:00
Summary:     Merged in ngoldbaum/yt (pull request #1686)

Fix API bug in YTArray casting during coercion from YTQuantity
Affected #:  2 files

diff -r 7c2d53feae18014f798008c038aeea9101cf1570 -r 87b696c1a0e3c58fd6719b1dfc973b82f1624c77 yt/units/tests/test_ytarray.py
--- a/yt/units/tests/test_ytarray.py
+++ b/yt/units/tests/test_ytarray.py
@@ -1009,7 +1009,18 @@
     V = YTQuantity(1.0, "statV")
     V_mks = V.to_equivalent("V", "SI")
     yield assert_array_almost_equal, V_mks.v, 1.0e8*V.v/speed_of_light_cm_per_s
-    
+
+def test_ytarray_coercion():
+    a = YTArray([1, 2, 3], 'cm')
+    q = YTQuantity(3, 'cm')
+    na = np.array([1, 2, 3])
+
+    assert_isinstance(a*q, YTArray)
+    assert_isinstance(q*na, YTArray)
+    assert_isinstance(q*3, YTQuantity)
+    assert_isinstance(q*np.float64(3), YTQuantity)
+    assert_isinstance(q*np.array(3), YTQuantity)
+
 def test_numpy_wrappers():
     a1 = YTArray([1, 2, 3], 'cm')
     a2 = YTArray([2, 3, 4, 5, 6], 'cm')

diff -r 7c2d53feae18014f798008c038aeea9101cf1570 -r 87b696c1a0e3c58fd6719b1dfc973b82f1624c77 yt/units/yt_array.py
--- a/yt/units/yt_array.py
+++ b/yt/units/yt_array.py
@@ -1085,7 +1085,7 @@
             if ret_class is YTQuantity:
                 # This happens if you do ndarray * YTQuantity. Explicitly
                 # casting to YTArray avoids creating a YTQuantity with size > 1
-                return YTArray(np.array(out_arr, unit))
+                return YTArray(np.array(out_arr), unit)
             return ret_class(np.array(out_arr, copy=False), unit)

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