summaryrefslogtreecommitdiff
path: root/numpy/testing/print_coercion_tables.py
diff options
context:
space:
mode:
authorMark Wiebe <mwwiebe@gmail.com>2011-01-28 16:27:56 -0800
committerMark Wiebe <mwwiebe@gmail.com>2011-01-28 16:27:56 -0800
commit67e5476a4178de55451501cfb01794c22d340b7a (patch)
tree2a24b021001658deb92230692f8fad62e9355791 /numpy/testing/print_coercion_tables.py
parentcdac1209a517bf0808f12340d21ac9d334f69485 (diff)
parentaedce0eb9fa63e7dec3c865374a64e11374c284c (diff)
downloadnumpy-67e5476a4178de55451501cfb01794c22d340b7a.tar.gz
Merge branch 'new_iterator' - new iterator, ufunc update, restore 1.5 ABI
New Iterator - Read doc/neps/new-iterator-ufunc.rst. UFunc Update - Change all ufunc functions to use the new iterator. This replaces the inline buffering with iterator buffering, except for the reductions and generalized ufunc which use updateifcopy at the moment. Also adds out= and order= parameters to all ufuncs. Restore 1.5 ABI - This was done by moving the new type numbers to the end of the type enumeration, and replacing all type promotion code with a table-based approach. The ArrFuncs was restored by putting the new type cast functions into the cast dictionary, originally designed just for custom types. Conflicts: numpy/core/src/multiarray/ctors.c numpy/core/tests/test_regression.py
Diffstat (limited to 'numpy/testing/print_coercion_tables.py')
-rwxr-xr-xnumpy/testing/print_coercion_tables.py19
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)