summaryrefslogtreecommitdiff
path: root/numpy/testing/_private/utils.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2019-05-27 11:39:13 -0700
committerGitHub <noreply@github.com>2019-05-27 11:39:13 -0700
commit3e3300ac119f9eb3f0afab2afd29b1816f965cad (patch)
tree05f0330a74d66d5c3825bfeddbfcab1062e32506 /numpy/testing/_private/utils.py
parentc976a9a44c08acf153723392906811d55294b8b4 (diff)
parent0d3d1b172b7f4c4775cd12138ec56edfac8a6dc2 (diff)
downloadnumpy-3e3300ac119f9eb3f0afab2afd29b1816f965cad.tar.gz
Merge pull request #13642 from mattip/issue-12942
BUG: special case object arrays when printing rel-, abs-error in assert_equal
Diffstat (limited to 'numpy/testing/_private/utils.py')
-rw-r--r--numpy/testing/_private/utils.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py
index ee8eac9e8..53181bc49 100644
--- a/numpy/testing/_private/utils.py
+++ b/numpy/testing/_private/utils.py
@@ -812,14 +812,22 @@ def assert_array_compare(comparison, x, y, err_msg='', verbose=True,
with contextlib.suppress(TypeError):
error = abs(x - y)
max_abs_error = error.max()
- remarks.append('Max absolute difference: '
- + array2string(max_abs_error))
+ if error.dtype == 'object':
+ remarks.append('Max absolute difference: '
+ + str(max_abs_error))
+ else:
+ remarks.append('Max absolute difference: '
+ + array2string(max_abs_error))
# note: this definition of relative error matches that one
# used by assert_allclose (found in np.isclose)
max_rel_error = (error / abs(y)).max()
- remarks.append('Max relative difference: '
- + array2string(max_rel_error))
+ if error.dtype == 'object':
+ remarks.append('Max relative difference: '
+ + str(max_rel_error))
+ else:
+ remarks.append('Max relative difference: '
+ + array2string(max_rel_error))
err_msg += '\n' + '\n'.join(remarks)
msg = build_err_msg([ox, oy], err_msg,