Author: Matti Picus <[email protected]>
Branch: 
Changeset: r67368:09061c91055f
Date: 2013-10-14 18:51 +0300
http://bitbucket.org/pypy/pypy/changeset/09061c91055f/

Log:    implement accumulate and remove unused argument to reduce()

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
@@ -850,7 +850,7 @@
             else:
                 out = w_out
             return getattr(interp_ufuncs.get(space), ufunc_name).reduce(
-                space, self, True, promote_to_largest, w_axis,
+                space, self, promote_to_largest, w_axis,
                 False, out, w_dtype, cumultative=cumultative)
         return func_with_new_name(impl, "reduce_%s_impl_%d_%d" % (ufunc_name,
                     promote_to_largest, cumultative))
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
@@ -75,6 +75,13 @@
                                             'output must be an array'))
         return self.call(space, args_w)
 
+    def descr_accumulate(self, space, w_obj, w_axis=None, w_dtype=None, 
w_out=None):
+        if space.is_none(w_axis) or w_axis is None:
+            w_axis = space.wrap(0)
+        return self.reduce(space, w_obj, False, #do not promote_to_largest
+                    w_axis, True, #keepdims must be true
+                    w_out, w_dtype, cumultative=True)
+
     @unwrap_spec(skipna=bool, keepdims=bool)
     def descr_reduce(self, space, w_obj, w_axis=None, w_dtype=None,
                      skipna=False, keepdims=False, w_out=None):
@@ -140,10 +147,11 @@
                                                 'output must be an array'))
         else:
             out = w_out
-        return self.reduce(space, w_obj, False, False, w_axis, keepdims, out,
+        promote_to_largest = False
+        return self.reduce(space, w_obj, promote_to_largest, w_axis, keepdims, 
out,
                            w_dtype)
 
-    def reduce(self, space, w_obj, multidim, promote_to_largest, w_axis,
+    def reduce(self, space, w_obj, promote_to_largest, w_axis,
                keepdims=False, out=None, dtype=None, cumultative=False):
         if self.argcount != 2:
             raise OperationError(space.w_ValueError, space.wrap("reduce only "
@@ -405,6 +413,7 @@
     __repr__ = interp2app(W_Ufunc.descr_repr),
 
     identity = GetSetProperty(W_Ufunc.descr_get_identity),
+    accumulate = interp2app(W_Ufunc.descr_accumulate),
     nin = interp_attrproperty("argcount", cls=W_Ufunc),
 
     reduce = interp2app(W_Ufunc.descr_reduce),
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to