Skip to content

Commit e0e8db8

Browse files
committed
..
1 parent ca6dca0 commit e0e8db8

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

python/sdist/amici/de_model.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import re
1010
from collections.abc import Callable, Sequence
1111
from itertools import chain
12+
from operator import itemgetter
1213
from typing import TYPE_CHECKING
1314

1415
import numpy as np
@@ -798,12 +799,16 @@ def num_events(self) -> int:
798799

799800
def num_events_solver(self) -> int:
800801
"""
801-
Number of Events.
802+
Number of Events that rely on numerical root-finding.
802803
803804
:return:
804805
number of event symbols (length of the root vector in AMICI)
805806
"""
806-
constant_syms = set(self.sym("k")) | set(self.sym("p"))
807+
constant_syms = (
808+
set(self.sym("k"))
809+
| set(self.sym("p"))
810+
| set(itemgetter(*self.static_indices("w"))(self.sym("w")))
811+
)
807812
return sum(
808813
not event.has_explicit_trigger_times(constant_syms)
809814
for event in self.events()
@@ -1307,13 +1312,12 @@ def parse_events(self) -> None:
13071312
# add roots of heaviside functions
13081313
self.add_component(root)
13091314

1310-
# # Substitute 'w' expressions into root expressions, to avoid rewriting
1311-
# # 'root.cpp' and 'stau.cpp' headers to include 'w.h'.
1312-
# for event in self.events():
1313-
# event.set_val(event.get_val().subs(w_toposorted))
1314-
13151315
# re-order events - first those that require root tracking, then the others
1316-
constant_syms = set(self.sym("k")) | set(self.sym("p"))
1316+
constant_syms = (
1317+
set(self.sym("k"))
1318+
| set(self.sym("p"))
1319+
| set(itemgetter(*self.static_indices("w"))(self.sym("w")))
1320+
)
13171321
self._events = list(
13181322
chain(
13191323
itertools.filterfalse(
@@ -2506,11 +2510,6 @@ def _process_heavisides(
25062510
heavisides = []
25072511
# run through the expression tree and get the roots
25082512
tmp_roots_old = self._collect_heaviside_roots((dxdt,))
2509-
# TODO remove: substitute 'w' symbols in the root expression by their equations,
2510-
# because currently,
2511-
# 1) root functions must not depend on 'w'
2512-
# FIXME 2) the check for time-dependence currently assumes only state
2513-
# variables are implicitly time-dependent
25142513
for tmp_root_old, tmp_x0_old in unique_preserve_order(tmp_roots_old):
25152514
# we want unique identifiers for the roots
25162515
tmp_root_new = self._get_unique_root(tmp_root_old, roots)

0 commit comments

Comments
 (0)