[pypy-commit] pypy fix-result-types: Fix dtype resolution in ufunc.reduce()

rlamy noreply at buildbot.pypy.org
Tue May 26 21:55:32 CEST 2015


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: fix-result-types
Changeset: r77600:e37b37435caf
Date: 2015-05-26 20:55 +0100
http://bitbucket.org/pypy/pypy/changeset/e37b37435caf/

Log:	Fix dtype resolution in ufunc.reduce()

diff --git a/pypy/module/micronumpy/test/test_ufuncs.py b/pypy/module/micronumpy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/micronumpy/test/test_ufuncs.py
@@ -1012,6 +1012,10 @@
             assert np.equal.reduce([1, 2], dtype=dtype) == True
             assert np.equal.reduce([1, 2, 0], dtype=dtype) == False
 
+    def test_reduce_fmax(self):
+        import numpy as np
+        assert np.fmax.reduce(np.arange(11).astype('b')) == 10
+
     def test_reduceND(self):
         from numpy import add, arange
         a = arange(12).reshape(3, 4)
diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py
--- a/pypy/module/micronumpy/ufuncs.py
+++ b/pypy/module/micronumpy/ufuncs.py
@@ -282,8 +282,9 @@
 
         if cumulative:
             dtype = self.find_binop_type(space, dtype)
-        elif self.bool_result:
-            dtype = get_dtype_cache(space).w_booldtype
+        else:
+            _, dtype, _ = self.find_specialization(space, dtype, dtype, out,
+                                                   casting='unsafe')
         call__array_wrap__ = True
         if shapelen > 1 and axis < shapelen:
             temp = None


More information about the pypy-commit mailing list