[pypy-commit] pypy numpypy-out: mark cause of failing test with xxx

mattip noreply at buildbot.pypy.org
Fri Feb 17 16:07:16 CET 2012


Author: mattip
Branch: numpypy-out
Changeset: r52587:e5f97ec08f2c
Date: 2012-02-17 17:06 +0200
http://bitbucket.org/pypy/pypy/changeset/e5f97ec08f2c/

Log:	mark cause of failing test with xxx

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
@@ -785,6 +785,8 @@
     def create_sig(self):
         if self.forced_result is not None:
             return self.forced_result.create_sig()
+        if self.shape != self.values.shape:
+            xxx 
         return signature.Call1(self.ufunc, self.name, self.calc_dtype,
                                self.values.create_sig())
 
@@ -838,8 +840,9 @@
         Call2.__init__(self, None, 'assign', shape, dtype, dtype, res, child)
 
     def create_sig(self):
-        return signature.ResultSignature(self.res_dtype, self.left.create_sig(),
+        sig = signature.ResultSignature(self.res_dtype, self.left.create_sig(),
                                          self.right.create_sig())
+        return sig
 
 def done_if_true(dtype, val):
     return dtype.itemtype.bool(val)
@@ -1088,7 +1091,7 @@
     """
     def setitem(self, item, value):
         self.invalidated()
-        self.dtype.setitem(self.storage, item, value)
+        self.dtype.setitem(self.storage, item, value.convert_to(self.dtype))
 
     def setshape(self, space, new_shape):
         self.shape = new_shape
diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -259,12 +259,23 @@
             else:
                 out = arr
             return space.wrap(out)
-        w_res = Call1(self.func, self.name, w_obj.shape, calc_dtype, res_dtype,
-                      w_obj, out)
-        w_obj.add_invalidates(w_res)
         if out:
+            #Test shape compatability
+            if not shape_agreement(space, w_obj.shape, out.shape):
+                raise operationerrfmt(space.w_ValueError,
+                    'output parameter shape mismatch, expecting [%s]' +
+                    ' , got [%s]', 
+                    ",".join([str(x) for x in shape]),
+                    ",".join([str(x) for x in out.shape]),
+                    )
+            w_res = Call1(self.func, self.name, out.shape, calc_dtype,
+                                         res_dtype, w_obj, out)
             #Force it immediately
             w_res.get_concrete()
+        else:
+            w_res = Call1(self.func, self.name, w_obj.shape, calc_dtype,
+                                         res_dtype, w_obj)
+        w_obj.add_invalidates(w_res)
         return w_res
 
 
diff --git a/pypy/module/micronumpy/test/test_outarg.py b/pypy/module/micronumpy/test/test_outarg.py
--- a/pypy/module/micronumpy/test/test_outarg.py
+++ b/pypy/module/micronumpy/test/test_outarg.py
@@ -32,7 +32,7 @@
         assert(b == [False,  True,  True]).all()
 
     def test_ufunc_out(self):
-        from _numpypy import array, negative, zeros
+        from _numpypy import array, negative, zeros, sin
         a = array([[1, 2], [3, 4]])
         c = zeros((2,2,2))
         b = negative(a + a, out=c[1])
@@ -46,14 +46,16 @@
         b = negative(3, out=c)
         assert b.dtype.kind == c.dtype.kind
         assert b.shape == c.shape
+        a = array([1, 2])
+        b = sin(a, out=c)
+        assert(c == [[-1, -2], [-1, -2]]).all()
+        b = sin(a, out=c+c)
+        assert (c == b).all()
 
         #Test shape agreement
         a=zeros((3,4))
         b=zeros((3,5))
         raises(ValueError, 'negative(a, out=b)')
-        raises(ValueError, 'negative(a, out=b)')
-
-        
 
     def test_ufunc_cast(self):
         from _numpypy import array, negative


More information about the pypy-commit mailing list