Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Dec 2, 2024
1 parent 78026f5 commit ec18e1a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/petab_test_suite/test_petab_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,15 @@ def _test_case(case, model_type, version):
)
solver = model.getSolver()
solver.setSteadyStateToleranceFactor(1.0)
problem_parameters = dict(
zip(problem.x_free_ids, problem.x_nominal_free, strict=True)
)

# simulate
ret = simulate_petab(
problem,
model,
problem_parameters=problem_parameters,
solver=solver,
log_level=logging.DEBUG,
)
Expand Down Expand Up @@ -138,7 +142,7 @@ def _test_case(case, model_type, version):
f"LLH: simulated: {llh}, expected: {gt_llh}, " f"match = {llhs_match}",
)

check_derivatives(problem, model, solver)
check_derivatives(problem, model, solver, problem_parameters)

if not all([llhs_match, simulations_match]) or not chi2s_match:
logger.error(f"Case {case} failed.")
Expand All @@ -150,7 +154,10 @@ def _test_case(case, model_type, version):


def check_derivatives(
problem: petab.Problem, model: amici.Model, solver: amici.Solver
problem: petab.Problem,
model: amici.Model,
solver: amici.Solver,
problem_parameters: dict[str, float],
) -> None:
"""Check derivatives using finite differences for all experimental
conditions
Expand All @@ -159,11 +166,8 @@ def check_derivatives(
problem: PEtab problem
model: AMICI model matching ``problem``
solver: AMICI solver
problem_parameters: Dictionary of problem parameters
"""
problem_parameters = {
t.Index: getattr(t, petab.NOMINAL_VALUE)
for t in problem.parameter_df.itertuples()
}
solver.setSensitivityMethod(amici.SensitivityMethod.forward)
solver.setSensitivityOrder(amici.SensitivityOrder.first)
# Required for case 9 to not fail in
Expand Down

0 comments on commit ec18e1a

Please sign in to comment.