diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2019-05-12 19:09:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-12 19:09:25 -0700 |
commit | 0a4d842b26c107f23fdf0217649b27c6f0ca8041 (patch) | |
tree | a4f9eceb7b6ad77244d77110b66a214fe26d0916 /numpy/testing/_private/utils.py | |
parent | d2d589703d5ee743251fbc6ea045f28e1c5e9e71 (diff) | |
parent | 366f9b8fc3dbc92baf7c5ba82a44b3fdb72e863d (diff) | |
download | numpy-0a4d842b26c107f23fdf0217649b27c6f0ca8041.tar.gz |
Merge pull request #13518 from hmaarrfk/faster_array_compare
MAINT: implement assert_array_compare without converting array to python list
Diffstat (limited to 'numpy/testing/_private/utils.py')
-rw-r--r-- | numpy/testing/_private/utils.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index b6ec768d3..ee8eac9e8 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -20,7 +20,7 @@ from warnings import WarningMessage import pprint from numpy.core import( - float32, empty, arange, array_repr, ndarray, isnat, array) + intp, float32, empty, arange, array_repr, ndarray, isnat, array) from numpy.lib.utils import deprecate if sys.version_info[0] >= 3: @@ -794,18 +794,17 @@ def assert_array_compare(comparison, x, y, err_msg='', verbose=True, if isinstance(val, bool): cond = val - reduced = [0] + reduced = array([val]) else: reduced = val.ravel() cond = reduced.all() - reduced = reduced.tolist() # The below comparison is a hack to ensure that fully masked # results, for which val.ravel().all() returns np.ma.masked, # do not trigger a failure (np.ma.masked != True evaluates as # np.ma.masked, which is falsy). if cond != True: - mismatch = 100.0 * reduced.count(0) / ox.size + mismatch = 100. * (reduced.size - reduced.sum(dtype=intp)) / ox.size remarks = ['Mismatch: {:.3g}%'.format(mismatch)] with errstate(invalid='ignore', divide='ignore'): |