summaryrefslogtreecommitdiff
path: root/numpy/testing/utils.py
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2009-12-07 22:22:10 +0000
committerPauli Virtanen <pav@iki.fi>2009-12-07 22:22:10 +0000
commit37f318c8be5c0f0eb7e7d217690446fbbc0d50d2 (patch)
tree394c264e85694a899211af67b5b0beedb74f33a0 /numpy/testing/utils.py
parentdfebefba4ff24627c0be0c97dc198a16573f2866 (diff)
downloadnumpy-37f318c8be5c0f0eb7e7d217690446fbbc0d50d2.tar.gz
BUG: make assert_equal and assert_almost_equal always display err_msg
Diffstat (limited to 'numpy/testing/utils.py')
-rw-r--r--numpy/testing/utils.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py
index 08cec9a8b..87ca389f7 100644
--- a/numpy/testing/utils.py
+++ b/numpy/testing/utils.py
@@ -273,9 +273,7 @@ def assert_equal(actual,desired,err_msg='',verbose=True):
assert_equal(actualr, desiredr)
assert_equal(actuali, desiredi)
except AssertionError:
- raise AssertionError("Items are not equal:\n" \
- "ACTUAL: %s\n" \
- "DESIRED: %s\n" % (str(actual), str(desired)))
+ raise AssertionError(msg)
# Inf/nan/negative zero handling
try:
@@ -413,6 +411,9 @@ def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=True):
except ValueError:
usecomplex = False
+ msg = build_err_msg([actual, desired], err_msg, verbose=verbose,
+ header='Arrays are not almost equal')
+
if usecomplex:
if iscomplexobj(actual):
actualr = real(actual)
@@ -430,15 +431,11 @@ def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=True):
assert_almost_equal(actualr, desiredr, decimal=decimal)
assert_almost_equal(actuali, desiredi, decimal=decimal)
except AssertionError:
- raise AssertionError("Items are not equal:\n" \
- "ACTUAL: %s\n" \
- "DESIRED: %s\n" % (str(actual), str(desired)))
+ raise AssertionError(msg)
if isinstance(actual, (ndarray, tuple, list)) \
or isinstance(desired, (ndarray, tuple, list)):
return assert_array_almost_equal(actual, desired, decimal, err_msg)
- msg = build_err_msg([actual, desired], err_msg, verbose=verbose,
- header='Arrays are not almost equal')
try:
# If one of desired/actual is not finite, handle it specially here:
# check that both are nan if any is a nan, and test for equality