summaryrefslogtreecommitdiff
path: root/numpy/testing/_private/utils.py
diff options
context:
space:
mode:
authorTim Hoffmann <2836374+timhoffm@users.noreply.github.com>2019-08-15 11:00:04 +0200
committerMatti Picus <matti.picus@gmail.com>2019-08-15 12:00:04 +0300
commit4b95b70eba7a721f1f4f4b7f7988ba06eda2bf89 (patch)
treefe7453568ae93a509bf9818d4d6e55bcca3624d9 /numpy/testing/_private/utils.py
parent4d734a4e6ef29d1f26a00b515f5f892ccdaf7ef9 (diff)
downloadnumpy-4b95b70eba7a721f1f4f4b7f7988ba06eda2bf89.tar.gz
ENH: Improve mismatch message of np.testing.assert_array_equal (#14203)
The original message included "Mismatch: 33.3%". It's not obvious what this percentage means. This commit changes the text to "Mismatched elements: 1 / 3 (33.3%)".
Diffstat (limited to 'numpy/testing/_private/utils.py')
-rw-r--r--numpy/testing/_private/utils.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py
index 87e66e06f..7aa5ef033 100644
--- a/numpy/testing/_private/utils.py
+++ b/numpy/testing/_private/utils.py
@@ -804,8 +804,11 @@ def assert_array_compare(comparison, x, y, err_msg='', verbose=True,
# do not trigger a failure (np.ma.masked != True evaluates as
# np.ma.masked, which is falsy).
if cond != True:
- mismatch = 100. * (reduced.size - reduced.sum(dtype=intp)) / ox.size
- remarks = ['Mismatch: {:.3g}%'.format(mismatch)]
+ n_mismatch = reduced.size - reduced.sum(dtype=intp)
+ percent_mismatch = 100 * n_mismatch / ox.size
+ remarks = [
+ 'Mismatched elements: {} / {} ({:.3g}%)'.format(
+ n_mismatch, ox.size, percent_mismatch)]
with errstate(invalid='ignore', divide='ignore'):
# ignore errors for non-numeric types