Skip to content

Commit

Permalink
Changed to dictionary outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanARashid committed Dec 9, 2024
1 parent dc99c0c commit 2505164
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tests/IVIMmodels/unit_tests/test_ivim_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,16 @@ def test_ivim_fit_saved(name, bvals, data, algorithm, xfail, kwargs, tolerances,
signal, ratio = signal_helper(data["data"])

tolerances = tolerances_helper(tolerances, ratio, data["noise"])
[f_fit, Dp_fit, D_fit] = fit.osipi_fit(signal, bvals)
#[f_fit, Dp_fit, D_fit] = fit.osipi_fit(signal, bvals)
fit_result = fit.osipi_fit(signal, bvals)
def to_list_if_needed(value):
return value.tolist() if isinstance(value, np.ndarray) else value
test_result = {
"name": name,
"algorithm": algorithm,
"f_fit": to_list_if_needed(f_fit),
"Dp_fit": to_list_if_needed(Dp_fit),
"D_fit": to_list_if_needed(D_fit),
"f_fit": to_list_if_needed(fit_result['f']),
"Dp_fit": to_list_if_needed(fit_result['D*']),
"D_fit": to_list_if_needed(fit_result['D']),
"f": to_list_if_needed(data['f']),
"Dp": to_list_if_needed(data['Dp']),
"D": to_list_if_needed(data['D']),
Expand All @@ -83,9 +84,9 @@ def to_list_if_needed(value):

record_property('test_data', test_result)

npt.assert_allclose(data['f'], f_fit, rtol=tolerances["rtol"]["f"], atol=tolerances["atol"]["f"])
npt.assert_allclose(data['f'], fit_result['f'], rtol=tolerances["rtol"]["f"], atol=tolerances["atol"]["f"])

if data['f']<0.80: # we need some signal for D to be detected
npt.assert_allclose(data['D'], fit_result['D'], rtol=tolerances["rtol"]["D"], atol=tolerances["atol"]["D"])
if data['f']>0.03: #we need some f for D* to be interpretable
npt.assert_allclose(data['Dp'], Dp_fit, rtol=tolerances["rtol"]["Dp"], atol=tolerances["atol"]["Dp"])
npt.assert_allclose(data['Dp'], fit_result['D*'], rtol=tolerances["rtol"]["Dp"], atol=tolerances["atol"]["Dp"])

0 comments on commit 2505164

Please sign in to comment.