Skip to content

Commit e1795b9

Browse files
committed
TST: add rtol and atol to assert_allclose_safely
Allow rtol, atol for wrapper around ``allclose``.
1 parent 796f63e commit e1795b9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

nibabel/testing/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def assert_dt_equal(a, b):
3737
assert_equal(np.dtype(a).str, np.dtype(b).str)
3838

3939

40-
def assert_allclose_safely(a, b, match_nans=True):
40+
def assert_allclose_safely(a, b, match_nans=True, rtol=1e-5, atol=1e-8):
4141
""" Allclose in integers go all wrong for large integers
4242
"""
4343
a = np.atleast_1d(a) # 0d arrays cannot be indexed
@@ -57,7 +57,7 @@ def assert_allclose_safely(a, b, match_nans=True):
5757
a = a.astype(float)
5858
if b.dtype.kind in 'ui':
5959
b = b.astype(float)
60-
assert_true(np.allclose(a, b))
60+
assert_true(np.allclose(a, b, rtol=rtol, atol=atol))
6161

6262

6363
def assert_re_in(regex, c, flags=0):

0 commit comments

Comments
 (0)