Skip to content

Commit

Permalink
Check for unsupported observable IDs in sigma expressions (#2563)
Browse files Browse the repository at this point in the history
Closes #2561.
  • Loading branch information
dweindl authored Nov 6, 2024
1 parent 2b05a19 commit 0009c4a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions python/sdist/amici/sbml_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -2052,12 +2052,26 @@ def _process_log_likelihood(
obs["reg_symbol"] = generate_regularization_symbol(obs_id)

if not event_reg:
sigmas = {
obs_id: self._sympy_from_sbml_math(sigma)
for obs_id, sigma in sigmas.items()
}
obs_syms = set(self.symbols[obs_symbol].keys())
for obs_id in self.symbols[obs_symbol]:
if (sigma := sigmas.get(str(obs_id))) and sigma.has(
*(obs_syms - {obs_id})
):
raise ValueError(
f"Sigma expression for {obs_id} ({sigma}) must not "
f"contain any observable symbols other than {obs_id}."
)
# check that only the corresponding observable ID is used in the
# sigma formula, but not any other observable ID
# https://github.com/AMICI-dev/AMICI/issues/2561
self.symbols[sigma_symbol] = {
symbol_with_assumptions(f"sigma_{obs_id}"): {
"name": f'sigma_{obs["name"]}',
"value": self._sympy_from_sbml_math(
sigmas.get(str(obs_id), "1.0")
),
"value": sigmas.get(str(obs_id), sp.Float(1.0)),
}
for obs_id, obs in self.symbols[obs_symbol].items()
}
Expand Down

0 comments on commit 0009c4a

Please sign in to comment.