From 74d4e1f816e822a8c5b0d66460e588848a94be6b Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 21 Feb 2024 23:03:39 +0100 Subject: [PATCH] Skip unnecessary toposorting in `DEModel._collect_heaviside_roots` (#2299) Sorting is only required if roots have been found. Most often this will not be the case. Only sort when necessary. --- python/sdist/amici/de_export.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/sdist/amici/de_export.py b/python/sdist/amici/de_export.py index 12cde4630f..0770894884 100644 --- a/python/sdist/amici/de_export.py +++ b/python/sdist/amici/de_export.py @@ -2724,6 +2724,9 @@ def _collect_heaviside_roots( elif arg.has(sp.Heaviside): root_funs.extend(self._collect_heaviside_roots(arg.args)) + if not root_funs: + return [] + # substitute 'w' expressions into root expressions now, to avoid # rewriting 'root.cpp' and 'stau.cpp' headers # to include 'w.h'