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

Proper error message in case of unsupported state-dependent sigmas #2239

Merged
merged 2 commits into from
Dec 18, 2023
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
17 changes: 17 additions & 0 deletions python/sdist/amici/de_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -2232,6 +2232,23 @@ def _compute_equation(self, name: str) -> None:
else:
raise ValueError(f"Unknown equation {name}")

if name in ("sigmay", "sigmaz"):
# check for states in sigma{y,z}, which is currently not supported
syms_x = self.sym("x")
syms_yz = self.sym(name.removeprefix("sigma"))
xs_in_sigma = {}
for sym_yz, eq_yz in zip(syms_yz, self._eqs[name]):
yz_free_syms = eq_yz.free_symbols
if tmp := {x for x in syms_x if x in yz_free_syms}:
xs_in_sigma[sym_yz] = tmp
if xs_in_sigma:
msg = ", ".join(
[f"{yz} depends on {xs}" for yz, xs in xs_in_sigma.items()]
)
raise NotImplementedError(
f"State-dependent observables are not supported, but {msg}."
)

if name == "root":
# Events are processed after the model has been set up.
# Equations are there, but symbols for roots must be added
Expand Down
Loading