[pypy-commit] pypy numpy-fixes: fix reduce for any, all
mattip
noreply at buildbot.pypy.org
Sun May 3 17:15:46 CEST 2015
Author: mattip <matti.picus at gmail.com>
Branch: numpy-fixes
Changeset: r77002:3bcccf53fb9c
Date: 2015-05-03 02:15 +0300
http://bitbucket.org/pypy/pypy/changeset/3bcccf53fb9c/
Log: fix reduce for any, all
diff --git a/pypy/module/micronumpy/ndarray.py b/pypy/module/micronumpy/ndarray.py
--- a/pypy/module/micronumpy/ndarray.py
+++ b/pypy/module/micronumpy/ndarray.py
@@ -1055,7 +1055,7 @@
# ----------------------- reduce -------------------------------
- def _reduce_ufunc_impl(ufunc_name, cumulative=False):
+ def _reduce_ufunc_impl(ufunc_name, cumulative=False, bool_result=False):
@unwrap_spec(keepdims=bool)
def impl(self, space, w_axis=None, w_dtype=None, w_out=None, keepdims=False):
if space.is_none(w_out):
@@ -1064,6 +1064,8 @@
raise oefmt(space.w_TypeError, 'output must be an array')
else:
out = w_out
+ if bool_result:
+ w_dtype = descriptor.get_dtype_cache(space).w_booldtype
return getattr(ufuncs.get(space), ufunc_name).reduce(
space, self, w_axis, keepdims, out, w_dtype, cumulative=cumulative)
return func_with_new_name(impl, "reduce_%s_impl_%d" % (ufunc_name, cumulative))
@@ -1072,8 +1074,8 @@
descr_prod = _reduce_ufunc_impl("multiply")
descr_max = _reduce_ufunc_impl("maximum")
descr_min = _reduce_ufunc_impl("minimum")
- descr_all = _reduce_ufunc_impl('logical_and')
- descr_any = _reduce_ufunc_impl('logical_or')
+ descr_all = _reduce_ufunc_impl('logical_and', bool_result=True)
+ descr_any = _reduce_ufunc_impl('logical_or', bool_result=True)
descr_cumsum = _reduce_ufunc_impl('add', cumulative=True)
descr_cumprod = _reduce_ufunc_impl('multiply', cumulative=True)
More information about the pypy-commit
mailing list