Skip to content

Commit b8c0fef

Browse files
authored
Faster DEModel._get_unique_root (#3024)
More efficient equality check: * Check equality before simplification * Respect DEModel._simplify for simplification This makes a very noticable difference for some models.
1 parent 1e8cf9c commit b8c0fef

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

python/sdist/amici/de_model.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2445,7 +2445,9 @@ def _get_unique_root(
24452445
return None
24462446

24472447
for root in roots:
2448-
if sp.simplify(root_found - root.get_val()).is_zero:
2448+
if (difference := (root_found - root.get_val())).is_zero or (
2449+
self._simplify and self._simplify(difference).is_zero
2450+
):
24492451
return root.get_sym()
24502452

24512453
# create an event for a new root function

0 commit comments

Comments
 (0)