diff options
author | chebee7i <chebee7i@gmail.com> | 2015-02-20 21:32:42 -0600 |
---|---|---|
committer | chebee7i <chebee7i@gmail.com> | 2015-02-20 21:41:44 -0600 |
commit | e1d3a0c66d719fe908de317c08b1234b71af196f (patch) | |
tree | b049785e40e8b12c757220a10992d237684b472c /numpy/testing/utils.py | |
parent | 2ae0529a5935c0eff0f72bb9f86d063537be250a (diff) | |
download | numpy-e1d3a0c66d719fe908de317c08b1234b71af196f.tar.gz |
ENH: Add `equal_nan` argument to allclose.
Diffstat (limited to 'numpy/testing/utils.py')
-rw-r--r-- | numpy/testing/utils.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py index b9bdaeb87..df186f63c 100644 --- a/numpy/testing/utils.py +++ b/numpy/testing/utils.py @@ -1244,7 +1244,7 @@ def _assert_valid_refcount(op): assert_(sys.getrefcount(i) >= rc) -def assert_allclose(actual, desired, rtol=1e-7, atol=0, +def assert_allclose(actual, desired, rtol=1e-7, atol=0, equal_nan=False, err_msg='', verbose=True): """ Raises an AssertionError if two objects are not equal up to desired @@ -1266,6 +1266,8 @@ def assert_allclose(actual, desired, rtol=1e-7, atol=0, Relative tolerance. atol : float, optional Absolute tolerance. + equal_nan : bool, optional. + If True, NaNs will compare equal. err_msg : str, optional The error message to be printed in case of failure. verbose : bool, optional @@ -1289,7 +1291,8 @@ def assert_allclose(actual, desired, rtol=1e-7, atol=0, """ import numpy as np def compare(x, y): - return np.core.numeric._allclose_points(x, y, rtol=rtol, atol=atol) + return np.core.numeric.isclose(x, y, rtol=rtol, atol=atol, + equal_nan=equal_nan) actual, desired = np.asanyarray(actual), np.asanyarray(desired) header = 'Not equal to tolerance rtol=%g, atol=%g' % (rtol, atol) |