Skip to content

Commit

Permalink
PEtab: fix missing parameters in fill_in_parameters (#2449)
Browse files Browse the repository at this point in the history
Allows providing only a subset of parameter to simulate_petab. The missing parameters are taken from nominalValues in the parameter table.

Fixes #2444. Nevertheless, exclude `Lang_PLOSComputBiol2024` to save time.
  • Loading branch information
dweindl committed May 15, 2024
1 parent e03f829 commit 44ed074
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
45 changes: 24 additions & 21 deletions python/sdist/amici/petab/simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,30 +166,33 @@ def simulate_petab(
amici_model=amici_model,
)

if problem_parameters is not None and not scaled_parameters:
problem_parameters = petab_problem.scale_parameters(problem_parameters)
scaled_parameters = True

if problem_parameters is None:
# scaled PEtab nominal values
problem_parameters = dict(
zip(
petab_problem.x_ids,
petab_problem.x_nominal_scaled,
strict=True,
)
problem_parameters = {}

# scaled PEtab nominal values
default_problem_parameters = dict(
zip(
petab_problem.x_ids,
petab_problem.get_x_nominal(scaled=scaled_parameters),
strict=True,
)
# depending on `fill_fixed_parameters` for parameter mapping, the
# parameter mapping may contain values instead of symbols for fixed
# parameters. In this case, we need to filter them here to avoid
# warnings in `fill_in_parameters`.
free_parameters = parameter_mapping.free_symbols
problem_parameters = {
par_id: par_value
for par_id, par_value in problem_parameters.items()
if par_id in free_parameters
}

elif not scaled_parameters:
problem_parameters = petab_problem.scale_parameters(problem_parameters)
)
# depending on `fill_fixed_parameters` for parameter mapping, the
# parameter mapping may contain values instead of symbols for fixed
# parameters. In this case, we need to filter them here to avoid
# warnings in `fill_in_parameters`.
free_parameters = parameter_mapping.free_symbols
default_problem_parameters = {
par_id: par_value
for par_id, par_value in default_problem_parameters.items()
if par_id in free_parameters
}

scaled_parameters = True
problem_parameters = default_problem_parameters | problem_parameters

# Get edatas
if edatas is None:
Expand Down
1 change: 1 addition & 0 deletions tests/benchmark-models/test_petab_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"Isensee_JCB2018",
"Beer_MolBioSystems2014",
"Alkan_SciSignal2018",
"Lang_PLOSComputBiol2024",
# excluded due to excessive numerical failures
"Crauste_CellSystems2017",
"Fujita_SciSignal2010",
Expand Down

0 comments on commit 44ed074

Please sign in to comment.