Skip to content

Commit

Permalink
Retry flaky test test_sbml_import_special_functions.py::test_special_…
Browse files Browse the repository at this point in the history
…likelihoods (#1795)

Allow for some retries, but reduce tolerances for FD check.
  • Loading branch information
dweindl authored May 10, 2022
1 parent 8fe8884 commit 8546384
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_python_cplusplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
- name: Python tests
run: |
source build/venv/bin/activate \
&& pip3 install coverage pytest pytest-cov \
&& pip3 install coverage pytest pytest-cov pytest-rerunfailures \
&& pytest \
--ignore-glob=*petab* \
--cov=amici \
Expand Down
8 changes: 5 additions & 3 deletions python/tests/test_sbml_import_special_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def model_special_likelihoods():
shutil.rmtree(outdir, ignore_errors=True)


# FD check fails occasionally, so give some extra tries
@pytest.mark.flaky(reruns=5)
def test_special_likelihoods(model_special_likelihoods):
"""Test special likelihood functions."""
model = model_special_likelihoods.getModel()
Expand All @@ -65,7 +67,7 @@ def test_special_likelihoods(model_special_likelihoods):

# make sure measurements are smaller for non-degenerate probability
y = edata.getObservedData()
y = tuple([val * np.random.uniform(0, 1) for val in y])
y = tuple(val * np.random.uniform(0, 1) for val in y)
edata.setObservedData(y)

# set sigmas
Expand Down Expand Up @@ -100,7 +102,7 @@ def test_special_likelihoods(model_special_likelihoods):
solver.setSensitivityMethod(sensi_method)
solver.setSensitivityOrder(amici.SensitivityOrder.first)
check_derivatives(
model, solver, edata, atol=1e-1, rtol=1e-1,
model, solver, edata, atol=1e-4, rtol=1e-3,
check_least_squares=False)

# Test for m > y, i.e. in region with 0 density
Expand All @@ -110,7 +112,7 @@ def test_special_likelihoods(model_special_likelihoods):

# make sure measurements are smaller for non-degenerate probability
y = edata.getObservedData()
y = tuple([val * np.random.uniform(0.5, 3) for val in y])
y = tuple(val * np.random.uniform(0.5, 3) for val in y)
edata.setObservedData(y)
edata.setObservedDataStdDev(sigmas)

Expand Down

0 comments on commit 8546384

Please sign in to comment.