From 3c7a21948016ccee64a0f28deae7be9583871091 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Fri, 23 Jun 2023 14:12:56 +0200 Subject: [PATCH 1/3] Fix sympy DeprecationWarning During SBML test case 01288: ``` E sympy.utilities.exceptions.SymPyDeprecationWarning: E E non-Expr objects in a Matrix is deprecated. Matrix represents E a mathematical matrix. To represent a container of non-numeric E entities, Use a list of lists, TableForm, NumPy array, or some E other data structure instead. E E See https://docs.sympy.org/latest/explanation/active-deprecations.html#deprecated-non-expr-in-matrix E for details. E E This has been deprecated since SymPy version 1.9. It E will be removed in a future version of SymPy. ``` --- 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 cb43a5093d..0f4b31981d 100644 --- a/python/sdist/amici/sbml_import.py +++ b/python/sdist/amici/sbml_import.py @@ -2205,7 +2205,12 @@ def _sympy_from_sbml_math( try: try: formula = sp.sympify( - _parse_logical_operators(math_string), locals=self._local_symbols + _parse_logical_operators(math_string), + locals={ + "true": sp.Float(1.0), + "false": sp.Float(0.0), + **self._local_symbols, + }, ) except TypeError as err: if str(err) == "BooleanAtom not allowed in this context.": From af956fc983aa5c365799a20e1fc5d145b2254a52 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Fri, 23 Jun 2023 16:37:06 +0200 Subject: [PATCH 2/3] .. --- python/sdist/amici/sbml_import.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/sdist/amici/sbml_import.py b/python/sdist/amici/sbml_import.py index 0f4b31981d..4bddc9e9f0 100644 --- a/python/sdist/amici/sbml_import.py +++ b/python/sdist/amici/sbml_import.py @@ -18,6 +18,7 @@ import libsbml as sbml import numpy as np import sympy as sp +from sympy.logic.boolalg import BooleanFalse, BooleanTrue from . import has_clibs from .constants import SymbolId @@ -1047,7 +1048,12 @@ def _process_reactions(self): reaction.getKineticLaw() or sp.Float(0) ) - self.flux_vector[reaction_index] = sym_math + self.flux_vector[reaction_index] = sym_math.subs( + { + BooleanTrue(): sp.Float(1.0), + BooleanFalse(): sp.Float(0.0), + } + ) if any( str(symbol) in reaction_ids for symbol in self.flux_vector[reaction_index].free_symbols From 537281a1c4d79ca6fa705d5f585a67a1e0f6a893 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Fri, 23 Jun 2023 19:58:01 +0200 Subject: [PATCH 3/3] .. --- python/sdist/amici/sbml_import.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/python/sdist/amici/sbml_import.py b/python/sdist/amici/sbml_import.py index 4bddc9e9f0..7abd0450a9 100644 --- a/python/sdist/amici/sbml_import.py +++ b/python/sdist/amici/sbml_import.py @@ -2211,12 +2211,7 @@ def _sympy_from_sbml_math( try: try: formula = sp.sympify( - _parse_logical_operators(math_string), - locals={ - "true": sp.Float(1.0), - "false": sp.Float(0.0), - **self._local_symbols, - }, + _parse_logical_operators(math_string), locals=self._local_symbols ) except TypeError as err: if str(err) == "BooleanAtom not allowed in this context.":