Author: mattip Branch: numpypy-axisops Changeset: r50951:d13df48602d0 Date: 2011-12-29 23:17 +0200 http://bitbucket.org/pypy/pypy/changeset/d13df48602d0/
Log: fixes for translation 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 @@ -283,8 +283,8 @@ descr_rmod = _binop_right_impl("mod") def _reduce_ufunc_impl(ufunc_name, promote_to_largest = False): - def impl(self, space, w_dim=None): - if w_dim is None: + def impl(self, space, w_dim=-1): + if isinstance(w_dim,int): w_dim = space.wrap(w_dim) return getattr(interp_ufuncs.get(space), ufunc_name).reduce(space, self, True, promote_to_largest, w_dim) 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 @@ -108,11 +108,7 @@ if self.argcount != 2: raise OperationError(space.w_ValueError, space.wrap("reduce only " "supported for binary functions")) - dim = -1 - if not space.is_w(w_dim, space.w_None): - dim = space.int_w(w_dim) - if not multidim and space.is_w(w_dim, space.w_None): - dim = 0 + dim = space.int_w(w_dim) assert isinstance(self, W_Ufunc2) obj = convert_to_array(space, w_obj) if isinstance(obj, Scalar): @@ -132,7 +128,8 @@ "%s.reduce without identity", self.name) if shapelen>1 and dim>=0: from pypy.module.micronumpy.interp_numarray import Reduce - return Reduce(self.func, self.name, dim, dtype, obj, self.identity) + return space.wrap(Reduce(self.func, self.name, dim, dtype, + obj, self.identity)) sig = find_sig(ReduceSignature(self.func, self.name, dtype, ScalarSignature(dtype), obj.create_sig(obj.shape)), obj) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit