From 89130a32745fe23d20bca30c8b7324efe4173185 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Sun, 10 Nov 2024 10:26:15 +0100 Subject: [PATCH] Optional warning in `fill_in_parameters` `amici.petab.conditions.fill_in_parameters` emits a warnings if parameters are supplied that don't occur in the parameter mapping. This is to point out potential issues with the parameter mapping. However, sometimes it's more convenient to silently ignore those extra parameters. Therefore, make this warning optional. --- python/sdist/amici/petab/conditions.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/python/sdist/amici/petab/conditions.py b/python/sdist/amici/petab/conditions.py index 08c2f90302..6538f9ef3d 100644 --- a/python/sdist/amici/petab/conditions.py +++ b/python/sdist/amici/petab/conditions.py @@ -41,6 +41,7 @@ def fill_in_parameters( scaled_parameters: bool, parameter_mapping: ParameterMapping, amici_model: AmiciModel, + warn_unused: bool = True, ) -> None: """Fill fixed and dynamic parameters into the edatas (in-place). @@ -59,9 +60,15 @@ def fill_in_parameters( Parameter mapping for all conditions. :param amici_model: AMICI model. + :param warn_unused: + Whether a warning should be emitted if not all problem parameters + were used. I.e., if there are parameters in `problem_parameters` + that are not in `parameter_mapping`. """ - if unused_parameters := ( - set(problem_parameters.keys()) - parameter_mapping.free_symbols + if warn_unused and ( + unused_parameters := ( + set(problem_parameters.keys()) - parameter_mapping.free_symbols + ) ): warnings.warn( "The following problem parameters were not used: "