Fix incorrect initialization for non-constant initial assignments#2939
Fix incorrect initialization for non-constant initial assignments#2939dweindl merged 8 commits intoAMICI-dev:mainfrom
Conversation
Fixes a bug where targets of initial assignments are not initialized correctly if the initial assignment expression is implicitly time-dependent. Fixes AMICI-dev#2936.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2939 +/- ##
==========================================
- Coverage 79.60% 79.02% -0.59%
==========================================
Files 362 362
Lines 23157 23175 +18
Branches 1588 1588
==========================================
- Hits 18435 18314 -121
- Misses 4710 4849 +139
Partials 12 12
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
python/sdist/amici/de_model.py
Outdated
| if replacement: | ||
| self._eqs["x0"][i_state] = new | ||
| made_substitutions = True | ||
| if made_substitutions: |
There was a problem hiding this comment.
Only apply this to new above?
| subs = toposort_symbols( | ||
| dict(zip(self.sym("x_rdata"), self.eq("x0"), strict=True)) | ||
| ) | ||
| subs = dict(zip(self._syms["w"], self.eq("w"), strict=True)) | subs |
There was a problem hiding this comment.
I think this has to be done in a loop as dict(zip(self._syms["w"], self.eq("w"), strict=True)) subs may introduce new self.sym("x_rdata") variables.
There was a problem hiding this comment.
w should not depend on x_rdata:
AMICI/python/sdist/amici/_codegen/cxx_functions.py
Lines 313 to 319 in e38afde
Unless the respective substitutions in w are only made later, but I don't think that is the case - the rateOf processing should happen last.
Fixes a bug where targets of initial assignments are not initialized correctly if the initial assignment expression is implicitly time-dependent. Fixes #2936.