Repository navigation
Fix uncompilable code for event assignments using expressions - #3416
Merged
dweindl merged 3 commits intoOct 19, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3416 +/- ##
=======================================
Coverage 80.10% 80.11%
=======================================
Files 320 320
Lines 22699 22705 +6
Branches 1536 1535 -1
=======================================
+ Hits 18183 18189 +6
Misses 4508 4508
Partials 8 8
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
dweindl
force-pushed
the
fix_event_assignment_expressions
branch
from
October 19, 2026 06:58
7359cee to
bde2a7e
Compare
Event assignments that reference expressions (`w`), e.g., targets of SBML assignment rules, resulted in uncompilable `deltax` code, as `deltax` is evaluated without access to `w`. Replace expressions by their definitions before substituting `x` by `x_old`, reusing the substitution for noise formulas from AMICI-dev#3388. This also fixes the JAX backend's `_delta_x`. Fixes AMICI-dev#3412. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The noise generated by `ExpData(rdata, ..., seed)` differs between platforms, which made the check for non-zero sensitivities fail on macOS and Windows. Use a fixed offset instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dweindl
force-pushed
the
fix_event_assignment_expressions
branch
from
October 19, 2026 08:09
bde2a7e to
2035fd2
Compare
Avoids merge conflicts with other pull requests adding tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 19, 2026
dweindl
marked this pull request as ready for review
October 19, 2026 12:44
FFroehlich
approved these changes
Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3412.
Event assignments that reference expressions (
w), e.g., targets of SBML assignment rules (y := 3 * x,E1: at time > 1: v = v + y), produced uncompilable code (deltax.cpp: 'y_' was not declared in this scope), sincedeltaxis evaluated without access tow.Event.get_state_updatenow takes a function that replaces expressions by their (recursively expanded) definitions, which is applied before substitutingxbyx_old. This reuses the substitution #3388 added for noise formulas, moved toDEModel._get_expression_substituter. Since the fix is inDEModel, it also applies to the JAX backend's_delta_xfor expressions that only depend on states, parameters and conservation law totals. JAX's_delta_xdoesn't gettand the Heaviside variables, so event assignments that depend ontimeorpiecewise, directly or via expressions, still fail there, as onmain(#3423).Event assignments using expressions that contain splines still don't compile (
deltax.cpp: 'spl_0_' was not declared in this scope), as onmain, since onlywanddwdxget the spline values (#3424).The new test
test_event_assignment_with_expressionsuses a chain of assignment rules depending on a state and a parameter. It checks the simulated values against the analytical solution, and forward and adjoint sensitivities against finite differences. Onmain, model compilation fails.🤖 Generated with Claude Code