summaryrefslogtreecommitdiff
path: root/numpy/testing/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/testing/utils.py')
-rw-r--r--numpy/testing/utils.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py
index ee7439d50..15323854d 100644
--- a/numpy/testing/utils.py
+++ b/numpy/testing/utils.py
@@ -180,7 +180,7 @@ def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=True):
verbose=verbose)
assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg
-def assert_array_compare(comparision, x, y, err_msg='', verbose=True,
+def assert_array_compare(comparison, x, y, err_msg='', verbose=True,
header=''):
from numpy.core import asarray
x = asarray(x)
@@ -195,10 +195,16 @@ def assert_array_compare(comparision, x, y, err_msg='', verbose=True,
verbose=verbose, header=header,
names=('x', 'y'))
assert cond, msg
- reduced = comparision(x, y).ravel()
- cond = reduced.all()
+ val = comparison(x,y)
+ if isinstance(val, bool):
+ cond = val
+ reduced = [0]
+ else:
+ reduced = val.ravel()
+ cond = reduced.all()
+ reduced = reduced.tolist()
if not cond:
- match = 100-100.0*reduced.tolist().count(1)/len(reduced)
+ match = 100-100.0*reduced.count(1)/len(reduced)
msg = build_err_msg([x, y],
err_msg
+ '\n(mismatch %s%%)' % (match,),