[pypy-commit] pypy numpy-impicit-convert: Convert second source of binary ops to numarray if needed

snus_mumrik noreply at buildbot.pypy.org
Thu Jun 23 22:33:58 CEST 2011


Author: Ilya Osadchiy <osadchiy.ilya at gmail.com>
Branch: numpy-impicit-convert
Changeset: r45094:51e8d063a32b
Date: 2011-06-23 23:38 +0300
http://bitbucket.org/pypy/pypy/changeset/51e8d063a32b/

Log:	Convert second source of binary ops to numarray if needed

diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -65,7 +65,7 @@
                 )
                 w_other.invalidates.append(res)
             else:
-                w_other = FloatWrapper(space.float_w(w_other))
+                w_other = access_as_array(space, w_other)
                 res = Call2(
                     function,
                     self,
diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -96,6 +96,15 @@
         for i in range(5):
             assert b[i] == i + 5
 
+    def test_add_other(self):
+        from numpy import array
+        a = array(range(5))
+        b = list(reversed(range(5)))
+        c = a + b
+        assert isinstance(c, array)
+        for i in range(5):
+            assert c[i] == 4
+
     def test_subtract(self):
         from numpy import array
         a = array(range(5))
@@ -213,4 +222,4 @@
         from numpy import array, mean
         a = array(range(5))
         assert a.mean() == 2.0
-        assert a[:4].mean() == 1.5
\ No newline at end of file
+        assert a[:4].mean() == 1.5


More information about the pypy-commit mailing list