diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2018-05-29 09:34:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-29 09:34:22 -0700 |
commit | 2d0ee485f754062621eb20e0959baf0d4e119b64 (patch) | |
tree | b3a3fefa936ebad1616f9db719d12b1279364899 /numpy/testing/_private/utils.py | |
parent | 80de28de294b24f926133a86176f64f6a13c5411 (diff) | |
parent | 6246cf19fdda3ccca4338dcec2f3956294e30ce7 (diff) | |
download | numpy-2d0ee485f754062621eb20e0959baf0d4e119b64.tar.gz |
Merge branch 'master' into npzfile-mappin
Diffstat (limited to 'numpy/testing/_private/utils.py')
-rw-r--r-- | numpy/testing/_private/utils.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index b0c0b0c48..a7935f175 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -771,7 +771,11 @@ def assert_array_compare(comparison, x, y, err_msg='', verbose=True, reduced = val.ravel() cond = reduced.all() reduced = reduced.tolist() - if not cond: + # 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: match = 100-100.0*reduced.count(1)/len(reduced) msg = build_err_msg([x, y], err_msg @@ -1369,16 +1373,20 @@ def _assert_valid_refcount(op): """ if not HAS_REFCOUNT: return True - import numpy as np + import numpy as np, gc b = np.arange(100*100).reshape(100, 100) c = b i = 1 - rc = sys.getrefcount(i) - for j in range(15): - d = op(b, c) - assert_(sys.getrefcount(i) >= rc) + gc.disable() + try: + rc = sys.getrefcount(i) + for j in range(15): + d = op(b, c) + assert_(sys.getrefcount(i) >= rc) + finally: + gc.enable() del d # for pyflakes |