diff options
author | Mark Wiebe <mwwiebe@gmail.com> | 2011-01-18 12:13:32 -0800 |
---|---|---|
committer | Mark Wiebe <mwwiebe@gmail.com> | 2011-01-18 12:13:32 -0800 |
commit | ee06d183c407ea315b2eb3ef41ee422b0ea30251 (patch) | |
tree | 63f342953c62be3ff4d991a6c2559c11d8233c53 /numpy/testing | |
parent | cce7e1fcfa49b2fe8e1b9c1530269fdcebade14b (diff) | |
download | numpy-ee06d183c407ea315b2eb3ef41ee422b0ea30251.tar.gz |
ENH: core: Start converting ufunc to new iterator, add PyArray_PromoteTypes
Diffstat (limited to 'numpy/testing')
-rwxr-xr-x | numpy/testing/print_coercion_tables.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/numpy/testing/print_coercion_tables.py b/numpy/testing/print_coercion_tables.py index 0c8a87d9a..7b5320d7e 100755 --- a/numpy/testing/print_coercion_tables.py +++ b/numpy/testing/print_coercion_tables.py @@ -14,6 +14,8 @@ class GenericObject: def __radd__(self, other): return self + dtype = np.dtype('O') + def print_cancast_table(ntypes): print 'X', for char in ntypes: print char, @@ -24,7 +26,7 @@ def print_cancast_table(ntypes): print int(np.can_cast(row, col)), print -def print_coercion_table(ntypes, inputfirstvalue, inputsecondvalue, firstarray): +def print_coercion_table(ntypes, inputfirstvalue, inputsecondvalue, firstarray, use_promote_types=False): print '+', for char in ntypes: print char, print @@ -46,11 +48,14 @@ def print_coercion_table(ntypes, inputfirstvalue, inputsecondvalue, firstarray): else: rowvalue = rowtype(inputfirstvalue) colvalue = coltype(inputsecondvalue) - value = np.add(rowvalue,colvalue) - if isinstance(value, np.ndarray): - char = value.dtype.char + if use_promote_types: + char = np.promote_types(rowvalue.dtype, colvalue.dtype).char else: - char = np.dtype(type(value)).char + value = np.add(rowvalue,colvalue) + if isinstance(value, np.ndarray): + char = value.dtype.char + else: + char = np.dtype(type(value)).char except ValueError: char = '!' except OverflowError: @@ -76,4 +81,6 @@ print_coercion_table(np.typecodes['All'], 0, 0, True) print print "array + neg scalar" print_coercion_table(np.typecodes['All'], 0, -1, True) - +print +print "promote_types" +print_coercion_table(np.typecodes['All'], 0, 0, False, True) |