diff options
author | Matti Picus <matti.picus@gmail.com> | 2018-10-23 12:35:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-23 12:35:38 +0300 |
commit | 7fbcc4eaf22a01ac3282179b49c6363485263fbf (patch) | |
tree | 336664500a6c426f9ef4cf3ccf624d0e1ce49be2 /numpy/testing/_private | |
parent | 2705bd5f9e6c7999e25d42daddd5bd11223472c8 (diff) | |
parent | be5ea7d92d542e7c7eb055c5831a79850f4bfbee (diff) | |
download | numpy-7fbcc4eaf22a01ac3282179b49c6363485263fbf.tar.gz |
Merge pull request #12243 from liwt31/fix_misleading_msg
BUG: Fix misleading assert message in assert_almost_equal #12200
Diffstat (limited to 'numpy/testing/_private')
-rw-r--r-- | numpy/testing/_private/utils.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index b37dac69d..20a7dfd0b 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -692,6 +692,9 @@ def assert_array_compare(comparison, x, y, err_msg='', verbose=True, x = array(x, copy=False, subok=True) y = array(y, copy=False, subok=True) + # original array for output formating + ox, oy = x, y + def isnumber(x): return x.dtype.char in '?bhilqpBHILQPefdgFDG' @@ -785,10 +788,10 @@ 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: - match = 100-100.0*reduced.count(1)/len(reduced) - msg = build_err_msg([x, y], + mismatch = 100.0 * reduced.count(0) / ox.size + msg = build_err_msg([ox, oy], err_msg - + '\n(mismatch %s%%)' % (match,), + + '\n(mismatch %s%%)' % (mismatch,), verbose=verbose, header=header, names=('x', 'y'), precision=precision) raise AssertionError(msg) |