From 19f7bafe9dfd83cea8fc982661d294b8296c296f Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 6 Mar 2024 20:10:23 +0100 Subject: [PATCH] SBML import: Evaluate initial assignments (#2359) Evaluate initial assignments to parameters to determine whether the targets are amici parameters or expressions. Related to https://github.com/AMICI-dev/AMICI/pull/2304. For example, it the initial assignment is `log(10)`, this should still be a parameter instead of an expression, but `sympy.log(10).is_Number` will be `False`. --- python/sdist/amici/sbml_import.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/sdist/amici/sbml_import.py b/python/sdist/amici/sbml_import.py index 61cb79043e..55d6dad903 100644 --- a/python/sdist/amici/sbml_import.py +++ b/python/sdist/amici/sbml_import.py @@ -1143,7 +1143,12 @@ def _process_parameters( # parameter ID => initial assignment sympy expression par_id_to_ia = { - par.getId(): ia + par.getId(): ia.subs( + { + BooleanTrue(): sp.Float(1.0), + BooleanFalse(): sp.Float(0.0), + } + ).evalf() for par in self.sbml.getListOfParameters() if (ia := self._get_element_initial_assignment(par.getId())) is not None