Skip to content

Commit c75bd32

Browse files
floating point error solved
1 parent 6f833d8 commit c75bd32

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

tests/IVIMmodels/unit_tests/test_ivim_fit.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,13 @@ def test_bounds(bound_input, eng):
126126
if fit.use_bounds["f"] or fit.use_bounds["D"] or fit.use_bounds["Dp"]:
127127
signal = signal_helper(data["data"])
128128
fit_result = fit.osipi_fit(signal, bvals)
129+
eps=1e-10 # without this margin it can cause floating point failures on mac systems
129130
if fit.use_bounds["D"]:
130-
assert bounds["D"][0] <= fit_result['D'] <= bounds["D"][1], f"Result {fit_result['D']} out of bounds for data: {name}"
131+
assert bounds["D"][0]-eps <= fit_result['D'] <= bounds["D"][1]+eps, f"Result {fit_result['D']} out of bounds for data: {name}"
131132
if fit.use_bounds["f"]:
132-
assert bounds["f"][0] <= fit_result['f'] <= bounds["f"][1], f"Result {fit_result['f']} out of bounds for data: {name}"
133+
assert bounds["f"][0]-eps <= fit_result['f'] <= bounds["f"][1]+eps, f"Result {fit_result['f']} out of bounds for data: {name}"
133134
if fit.use_bounds["Dp"]:
134-
assert bounds["Dp"][0] <= fit_result['Dp'] <= bounds["Dp"][1], f"Result {fit_result['Dp']} out of bounds for data: {name}"
135+
assert bounds["Dp"][0]-eps <= fit_result['Dp'] <= bounds["Dp"][1]+eps, f"Result {fit_result['Dp']} out of bounds for data: {name}"
135136
# S0 is not returned as argument...
136137
#assert bounds[0][3] <= fit_result['S0'] <= bounds[1][3], f"Result {fit_result['S0']} out of bounds for data: {name}"
137138
'''if fit.use_initial_guess:

0 commit comments

Comments
 (0)