Author: Ronan Lamy <[email protected]>
Branch: fix-result-types
Changeset: r77403:4bf5c0716f7b
Date: 2015-05-19 19:38 +0100
http://bitbucket.org/pypy/pypy/changeset/4bf5c0716f7b/

Log:    kill unused find_unaryop_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
@@ -134,35 +134,6 @@
     dt2 = as_dtype(space, w_type2, allow_None=False)
     return _promote_types(space, dt1, dt2)
 
[email protected]_safe
-def find_unaryop_result_dtype(space, dt, promote_to_float=False,
-        promote_bools=False, promote_to_largest=False):
-    if dt.is_object():
-        return dt
-    if promote_to_largest:
-        if dt.kind == NPY.GENBOOLLTR or dt.kind == NPY.SIGNEDLTR:
-            if dt.elsize * 8 < LONG_BIT:
-                return get_dtype_cache(space).w_longdtype
-        elif dt.kind == NPY.UNSIGNEDLTR:
-            if dt.elsize * 8 < LONG_BIT:
-                return get_dtype_cache(space).w_ulongdtype
-        else:
-            assert dt.kind == NPY.FLOATINGLTR or dt.kind == NPY.COMPLEXLTR
-        return dt
-    if promote_bools and (dt.kind == NPY.GENBOOLLTR):
-        return get_dtype_cache(space).w_int8dtype
-    if promote_to_float:
-        if dt.kind == NPY.FLOATINGLTR or dt.kind == NPY.COMPLEXLTR:
-            return dt
-        if dt.num >= NPY.INT:
-            return get_dtype_cache(space).w_float64dtype
-        for bytes, dtype in get_dtype_cache(space).float_dtypes_by_num_bytes:
-            if (dtype.kind == NPY.FLOATINGLTR and
-                    dtype.itemtype.get_element_size() >
-                    dt.itemtype.get_element_size()):
-                return dtype
-    return dt
-
 def find_binop_result_dtype(space, dt1, dt2):
     if dt2 is None:
         return dt1
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
@@ -1,7 +1,7 @@
 from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest
 from pypy.module.micronumpy.descriptor import get_dtype_cache
 from pypy.module.micronumpy.casting import (
-    find_unaryop_result_dtype, find_binop_result_dtype, can_cast_type)
+    find_binop_result_dtype, can_cast_type)
 
 
 class AppTestNumSupport(BaseNumpyAppTest):
@@ -159,51 +159,3 @@
         assert find_binop_result_dtype(space, c64_dtype, float64_dtype) is 
c128_dtype
         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
-
-    def test_unaryops(self, space):
-        bool_dtype = get_dtype_cache(space).w_booldtype
-        int8_dtype = get_dtype_cache(space).w_int8dtype
-        uint8_dtype = get_dtype_cache(space).w_uint8dtype
-        int16_dtype = get_dtype_cache(space).w_int16dtype
-        uint16_dtype = get_dtype_cache(space).w_uint16dtype
-        int32_dtype = get_dtype_cache(space).w_int32dtype
-        uint32_dtype = get_dtype_cache(space).w_uint32dtype
-        long_dtype = get_dtype_cache(space).w_longdtype
-        ulong_dtype = get_dtype_cache(space).w_ulongdtype
-        int64_dtype = get_dtype_cache(space).w_int64dtype
-        uint64_dtype = get_dtype_cache(space).w_uint64dtype
-        float16_dtype = get_dtype_cache(space).w_float16dtype
-        float32_dtype = get_dtype_cache(space).w_float32dtype
-        float64_dtype = get_dtype_cache(space).w_float64dtype
-
-        # Normal rules, everything returns itself
-        assert find_unaryop_result_dtype(space, bool_dtype) is bool_dtype
-        assert find_unaryop_result_dtype(space, int8_dtype) is int8_dtype
-        assert find_unaryop_result_dtype(space, uint8_dtype) is uint8_dtype
-        assert find_unaryop_result_dtype(space, int16_dtype) is int16_dtype
-        assert find_unaryop_result_dtype(space, uint16_dtype) is uint16_dtype
-        assert find_unaryop_result_dtype(space, int32_dtype) is int32_dtype
-        assert find_unaryop_result_dtype(space, uint32_dtype) is uint32_dtype
-        assert find_unaryop_result_dtype(space, long_dtype) is long_dtype
-        assert find_unaryop_result_dtype(space, ulong_dtype) is ulong_dtype
-        assert find_unaryop_result_dtype(space, int64_dtype) is int64_dtype
-        assert find_unaryop_result_dtype(space, uint64_dtype) is uint64_dtype
-        assert find_unaryop_result_dtype(space, float32_dtype) is float32_dtype
-        assert find_unaryop_result_dtype(space, float64_dtype) is float64_dtype
-
-        # Coerce to floats, some of these will eventually be float16, or
-        # whatever our smallest float type is.
-        assert find_unaryop_result_dtype(space, bool_dtype, 
promote_to_float=True) is float16_dtype
-        assert find_unaryop_result_dtype(space, int8_dtype, 
promote_to_float=True) is float16_dtype
-        assert find_unaryop_result_dtype(space, uint8_dtype, 
promote_to_float=True) is float16_dtype
-        assert find_unaryop_result_dtype(space, int16_dtype, 
promote_to_float=True) is float32_dtype
-        assert find_unaryop_result_dtype(space, uint16_dtype, 
promote_to_float=True) is float32_dtype
-        assert find_unaryop_result_dtype(space, int32_dtype, 
promote_to_float=True) is float64_dtype
-        assert find_unaryop_result_dtype(space, uint32_dtype, 
promote_to_float=True) is float64_dtype
-        assert find_unaryop_result_dtype(space, int64_dtype, 
promote_to_float=True) is float64_dtype
-        assert find_unaryop_result_dtype(space, uint64_dtype, 
promote_to_float=True) is float64_dtype
-        assert find_unaryop_result_dtype(space, float32_dtype, 
promote_to_float=True) is float32_dtype
-        assert find_unaryop_result_dtype(space, float64_dtype, 
promote_to_float=True) is float64_dtype
-
-        # promote bools, happens with sign ufunc
-        assert find_unaryop_result_dtype(space, bool_dtype, 
promote_bools=True) is int8_dtype
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to