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

Check for unsupported observable IDs in sigma expressions #2563

Merged
merged 6 commits into from
Nov 6, 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
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
Loading