From 1c30922356796862366caad672d0b4ac04e9ebd6 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Thu, 28 Aug 2025 14:41:28 +0200 Subject: [PATCH] Fix handling of time in algebraic rules Fixes the following error: ``` > if sbml_var.isSetConstant() and sbml_var.getConstant(): ^^^^^^^^^^^^^^^^^^^^^^ E AttributeError: 'NoneType' object has no attribute 'isSetConstant' ``` --- python/sdist/amici/sbml_import.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/sdist/amici/sbml_import.py b/python/sdist/amici/sbml_import.py index ec827a5ed4..0b83d04e01 100644 --- a/python/sdist/amici/sbml_import.py +++ b/python/sdist/amici/sbml_import.py @@ -1570,7 +1570,13 @@ def _process_rule_algebraic(self, rule: libsbml.AlgebraicRule): # completely determined by other constructs in the model" # find those elements: for symbol in formula.free_symbols: + if symbol == sbml_time_symbol: + continue sbml_var = self.sbml.getElementBySId(str(symbol)) + if sbml_var is None: + raise SBMLException( + f"Algebraic rule references unexpected symbol '{symbol}'." + ) # This means that at least this entity must # not have the attribute constant=“true” if sbml_var.isSetConstant() and sbml_var.getConstant():