Skip to content

Commit

Permalink
Fix _collect_heaviside_roots for sympy.Heaviside arguments
Browse files Browse the repository at this point in the history
Previously, if dxdt was a sympy.Heaviside, it wasn't correctly processed, because only its arguments were checked.
That means, root-finding would not be enabled for this discontinuity.

This would happen if a Rule or KineticLaw is a plain Piecewise function (not embedded inside a more complex expression).

Fixes AMICI-dev#2545.
  • Loading branch information
dweindl committed Oct 17, 2024
1 parent 2c957c8 commit edc8c45
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/sdist/amici/de_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2226,7 +2226,7 @@ def _get_unique_root(

def _collect_heaviside_roots(
self,
args: Sequence[sp.Expr],
args: Sequence[sp.Basic],
) -> list[sp.Expr]:
"""
Recursively checks an expression for the occurrence of Heaviside
Expand Down Expand Up @@ -2288,7 +2288,7 @@ def _process_heavisides(
# replace them later by the new expressions
heavisides = []
# run through the expression tree and get the roots
tmp_roots_old = self._collect_heaviside_roots(dxdt.args)
tmp_roots_old = self._collect_heaviside_roots((dxdt,))
for tmp_old in unique_preserve_order(tmp_roots_old):
# we want unique identifiers for the roots
tmp_new = self._get_unique_root(tmp_old, roots)
Expand Down

0 comments on commit edc8c45

Please sign in to comment.