[pypy-commit] pypy matrixmath-dot: remove all ufunc changes, revert to default version

mattip noreply at buildbot.pypy.org
Sun Dec 25 01:02:02 CET 2011


Author: mattip
Branch: matrixmath-dot
Changeset: r50842:495d8ce73189
Date: 2011-12-23 15:54 +0200
http://bitbucket.org/pypy/pypy/changeset/495d8ce73189/

Log:	remove all ufunc changes, revert to default version

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
@@ -280,14 +280,13 @@
     def _reduce_ufunc_impl(ufunc_name):
         def impl(self, space):
             return getattr(interp_ufuncs.get(space), ufunc_name).reduce(space,
-                   self, multidim=True, promote_to_largest=promote_to_largest)
+                   self, multidim=True)
         return func_with_new_name(impl, "reduce_%s_impl" % ufunc_name)
 
-    descr_sum = _reduce_ufunc_impl("add", False)
-    descr_prod = _reduce_ufunc_impl("multiply", False)
-    descr_max = _reduce_ufunc_impl("maximum", False)
-    descr_min = _reduce_ufunc_impl("minimum", False)
-    descr_sumpromote = _reduce_ufunc_impl("add", True)
+    descr_sum = _reduce_ufunc_impl("add")
+    descr_prod = _reduce_ufunc_impl("multiply")
+    descr_max = _reduce_ufunc_impl("maximum")
+    descr_min = _reduce_ufunc_impl("minimum")
 
     def _reduce_argmax_argmin_impl(op_name):
         reduce_driver = jit.JitDriver(
@@ -631,7 +630,7 @@
         return w_result
 
     def descr_mean(self, space):
-        return space.div(self.descr_sumpromote(space), 
+        return space.div(self.descr_sum(space), 
                          space.wrap(self.size))
 
     def descr_nonzero(self, space):
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
@@ -49,7 +49,7 @@
     def descr_reduce(self, space, w_obj):
         return self.reduce(space, w_obj, multidim=False)
 
-    def reduce(self, space, w_obj, multidim, promote_to_largest):
+    def reduce(self, space, w_obj, multidim):
         from pypy.module.micronumpy.interp_numarray import convert_to_array, Scalar
         
         if self.argcount != 2:
@@ -136,19 +136,12 @@
         W_Ufunc.__init__(self, name, promote_to_float, promote_bools, identity)
         self.func = func
         self.comparison_func = comparison_func
-        self.signature = signature.Call2(func)
-        self.reduce_signature = signature.BaseSignature()
 
     def call(self, space, args_w):
         from pypy.module.micronumpy.interp_numarray import (Call2,
             convert_to_array, Scalar, shape_agreement)
-        #TODO: use of w_ssd, w_osd can be optimized.
-        if len(args_w)<4:
-            [w_lhs, w_rhs] = args_w
-            w_ssd = space.newlist([space.wrap(-1)]*2)
-            w_osd = space.newlist([space.wrap(-1)]*2)
-        else:
-            [w_lhs, w_rhs, w_ssd, w_osd] = args_w
+
+        [w_lhs, w_rhs] = args_w
         w_lhs = convert_to_array(space, w_lhs)
         w_rhs = convert_to_array(space, w_rhs)
         calc_dtype = find_binop_result_dtype(space,
@@ -166,17 +159,10 @@
                 w_rhs.value.convert_to(calc_dtype)
             )
 
-        new_shape = []
-        ssd = [space.int_w(s) for s in space.listview(w_ssd)]
-        osd = [space.int_w(s) for s in space.listview(w_osd)]
-        if  ssd[0]<0:
-            new_shape = shape_agreement(space, w_lhs.shape, w_rhs.shape)
-        else:
-            #Assumption (should have been checked in call): 
-            #w_lhs.shape[ssd[1]] == w_rhs.shape[osd[1]]
-            new_shape = [w_lhs.shape[ssd[1]]]
-        w_res = Call2(new_sig, new_shape, calc_dtype,
-                      res_dtype, w_lhs, w_rhs, ssd, osd)
+        new_shape = shape_agreement(space, w_lhs.shape, w_rhs.shape)
+        w_res = Call2(self.func, self.name,
+                      new_shape, calc_dtype,
+                      res_dtype, w_lhs, w_rhs)
         w_lhs.add_invalidates(w_res)
         w_rhs.add_invalidates(w_res)
         return w_res
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
@@ -716,7 +716,6 @@
         a = array(range(5))
         b = a.sum()
         assert b == 10
-        assert isinstance(b,int)
         assert a[:4].sum() == 6
 
         a = array([True] * 5, bool)


More information about the pypy-commit mailing list