Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEtab: Fix warning from fill_in_parameters with fixed parameters #1509

Merged
merged 7 commits into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion pypesto/objective/amici/amici.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,12 @@ def __init__(
# (relevant for setting ``plist`` in ExpData later on)
self.parameter_mapping = parameter_mapping
# parameter mapping independent of fixed parameters
# (i.e., all objective parameters are included as parameter IDs,
# not as their values)
self._parameter_mapping_full = copy.deepcopy(parameter_mapping)
# IDs of fixed `Problem` parameters
self._fixed_parameter_ids = []

# If supported, enable `guess_steadystate` by default. If not
# supported, disable by default. If requested but unsupported, raise.
if (
Expand Down Expand Up @@ -478,8 +483,16 @@ def call_unprocessed(
edatas = self.edatas
if parameter_mapping is None:
parameter_mapping = self.parameter_mapping
# Some parameters may appear estimated in the original compiled model,
# but then are fixed during parameter estimation. These are removed
# from the parameter vector to avoid warnings about unused parameters.
x_dct_free = {
par_id: val
for par_id, val in x_dct.items()
if par_id not in self._fixed_parameter_ids
}
ret = self.calculator(
x_dct=x_dct,
x_dct=x_dct_free,
sensi_orders=sensi_orders,
mode=mode,
amici_model=self.amici_model,
Expand Down Expand Up @@ -679,6 +692,7 @@ def update_from_problem(
# and replace the IDs of all fixed parameters by their respective
# values.
self.parameter_mapping = copy.deepcopy(self._parameter_mapping_full)
self._fixed_parameter_ids = [self.x_ids[i] for i in x_fixed_indices]
if not len(x_fixed_indices):
return

Expand All @@ -693,3 +707,9 @@ def update_from_problem(
) in condition_mapping.map_sim_var.items():
if (val := id_to_val.get(mapped_to_par)) is not None:
condition_mapping.map_sim_var[model_par] = val
for (
model_par,
mapped_to_par,
) in condition_mapping.map_sim_fix.items():
if (val := id_to_val.get(mapped_to_par)) is not None:
condition_mapping.map_sim_fix[model_par] = val
Loading