[pypy-commit] pypy numpypy-out: most tests pass, translation demands assert to be removed later

mattip noreply at buildbot.pypy.org
Wed Feb 15 22:44:23 CET 2012


Author: mattip
Branch: numpypy-out
Changeset: r52523:f5c2c9a63515
Date: 2012-02-15 23:42 +0200
http://bitbucket.org/pypy/pypy/changeset/f5c2c9a63515/

Log:	most tests pass, translation demands assert to be removed later

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
@@ -723,6 +723,7 @@
         raise NotImplementedError
 
     def compute(self):
+        assert isinstance(self.res, BaseArray)
         ra = ResultArray(self, self.size, self.shape, self.res_dtype,
                                                                 self.res)
         loop.compute(ra)
@@ -773,7 +774,6 @@
 class Call1(VirtualArray):
     def __init__(self, ufunc, name, shape, calc_dtype, res_dtype, values,
                                                             out_arg=None):
-        xxx
         VirtualArray.__init__(self, name, shape, res_dtype, out_arg)
         self.values = values
         self.size = values.size
@@ -799,6 +799,8 @@
             out_arg=None):
         VirtualArray.__init__(self, name, shape, res_dtype, out_arg)
         self.ufunc = ufunc
+        assert isinstance(left, BaseArray)
+        assert isinstance(right, BaseArray)
         self.left = left
         self.right = right
         self.calc_dtype = calc_dtype
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
@@ -227,9 +227,8 @@
         self.bool_result = bool_result
 
     def call(self, space, args_w):
-        from pypy.module.micronumpy.interp_numarray import (Call1,
+        from pypy.module.micronumpy.interp_numarray import (Call1, BaseArray,
             convert_to_array, Scalar, shape_agreement)
-
         if len(args_w)<2:
             [w_obj] = args_w
             out = None
@@ -243,8 +242,9 @@
                                   promote_to_float=self.promote_to_float,
                                   promote_bools=self.promote_bools)
         if out:
-            ret_shape = shape_agreement(space, w_obj.shape, out.shape)
-            assert(ret_shape is not None)
+            if not isinstance(out, BaseArray):
+                raise OperationError(space.w_TypeError, space.wrap(
+                                                'output must be an array'))
             res_dtype = out.find_dtype()
         elif self.bool_result:
             res_dtype = interp_dtype.get_dtype_cache(space).w_booldtype
@@ -254,8 +254,11 @@
             arr = self.func(calc_dtype, w_obj.value.convert_to(calc_dtype))
             if isinstance(out,Scalar):
                 out.value=arr
+            elif isinstance(out, BaseArray):
+                out.fill(space, arr)
+            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)


More information about the pypy-commit mailing list