[pypy-commit] pypy fix-result-types: kill unused flags in find_binop_result_dtype()

rlamy noreply at buildbot.pypy.org
Tue May 19 20:38:08 CEST 2015


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: fix-result-types
Changeset: r77402:d895ec8f9a3b
Date: 2015-05-19 19:22 +0100
http://bitbucket.org/pypy/pypy/changeset/d895ec8f9a3b/

Log:	kill unused flags in find_binop_result_dtype()

diff --git a/pypy/module/micronumpy/casting.py b/pypy/module/micronumpy/casting.py
--- a/pypy/module/micronumpy/casting.py
+++ b/pypy/module/micronumpy/casting.py
@@ -163,18 +163,14 @@
                 return dtype
     return dt
 
-def find_binop_result_dtype(space, dt1, dt2, promote_to_float=False,
-        promote_bools=False):
+def find_binop_result_dtype(space, dt1, dt2):
     if dt2 is None:
         return dt1
     if dt1 is None:
         return dt2
-    # Some operations promote op(bool, bool) to return int8, rather than bool
-    if promote_bools and (dt1.kind == dt2.kind == NPY.GENBOOLLTR):
-        return get_dtype_cache(space).w_int8dtype
-    return _promote_types(space, dt1, dt2, promote_to_float)
+    return _promote_types(space, dt1, dt2)
 
-def _promote_types(space, dt1, dt2, promote_to_float=False):
+def _promote_types(space, dt1, dt2):
     if dt1.num == NPY.OBJECT or dt2.num == NPY.OBJECT:
         return get_dtype_cache(space).w_objectdtype
 
@@ -201,8 +197,6 @@
         else:
             raise OperationError(space.w_TypeError, space.wrap("Unsupported types"))
 
-    if promote_to_float:
-        return find_unaryop_result_dtype(space, dt2, promote_to_float=True)
     # If they're the same kind, choose the greater one.
     if dt1.kind == dt2.kind and not dt2.is_flexible():
         if dt2.num == NPY.HALF:
diff --git a/pypy/module/micronumpy/test/test_casting.py b/pypy/module/micronumpy/test/test_casting.py
--- a/pypy/module/micronumpy/test/test_casting.py
+++ b/pypy/module/micronumpy/test/test_casting.py
@@ -151,7 +151,6 @@
         cld_dtype = get_dtype_cache(space).w_complexlongdtype
         fld_dtype = get_dtype_cache(space).w_floatlongdtype
 
-        # Basic pairing
         assert find_binop_result_dtype(space, bool_dtype, bool_dtype) is bool_dtype
         assert find_binop_result_dtype(space, bool_dtype, float64_dtype) is float64_dtype
         assert find_binop_result_dtype(space, float64_dtype, bool_dtype) is float64_dtype
@@ -161,14 +160,6 @@
         assert find_binop_result_dtype(space, c64_dtype, fld_dtype) is cld_dtype
         assert find_binop_result_dtype(space, c128_dtype, fld_dtype) is cld_dtype
 
-        # With promote bool (happens on div), the result is that the op should
-        # promote bools to int8
-        assert find_binop_result_dtype(space, bool_dtype, bool_dtype, promote_bools=True) is int8_dtype
-        assert find_binop_result_dtype(space, bool_dtype, float64_dtype, promote_bools=True) is float64_dtype
-
-        # Coerce to floats
-        assert find_binop_result_dtype(space, bool_dtype, float64_dtype, promote_to_float=True) is float64_dtype
-
     def test_unaryops(self, space):
         bool_dtype = get_dtype_cache(space).w_booldtype
         int8_dtype = get_dtype_cache(space).w_int8dtype


More information about the pypy-commit mailing list