From bceff6cb931128e85cc8bbc21ca0ee7b49461d53 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 15 May 2024 12:54:40 +0200 Subject: [PATCH] PEtab: fix missing parameters in fill_in_parameters Allows providing only a subset of parameter to simulate_petab. The missing parameters are taken from nominalValues in the parameter table. Fixes #2444 --- python/sdist/amici/petab/simulations.py | 45 +++++++++++++------------ 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/python/sdist/amici/petab/simulations.py b/python/sdist/amici/petab/simulations.py index e80e40a94b..2cbed98dce 100644 --- a/python/sdist/amici/petab/simulations.py +++ b/python/sdist/amici/petab/simulations.py @@ -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: