Skip to content

Commit

Permalink
Optional warning in fill_in_parameters
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
dweindl committed Nov 10, 2024
1 parent 0009c4a commit 89130a3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions python/sdist/amici/petab/conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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: "
Expand Down

0 comments on commit 89130a3

Please sign in to comment.