Skip to content

Commit 773f8d2

Browse files
authored
Fix sympy DeprecationWarning (#2131)
During SBML test case 01288 when handling `true`/`false`: ``` 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. ```
1 parent e744b5c commit 773f8d2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

python/sdist/amici/sbml_import.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import libsbml as sbml
1919
import numpy as np
2020
import sympy as sp
21+
from sympy.logic.boolalg import BooleanFalse, BooleanTrue
2122

2223
from . import has_clibs
2324
from .constants import SymbolId
@@ -1047,7 +1048,12 @@ def _process_reactions(self):
10471048
reaction.getKineticLaw() or sp.Float(0)
10481049
)
10491050

1050-
self.flux_vector[reaction_index] = sym_math
1051+
self.flux_vector[reaction_index] = sym_math.subs(
1052+
{
1053+
BooleanTrue(): sp.Float(1.0),
1054+
BooleanFalse(): sp.Float(0.0),
1055+
}
1056+
)
10511057
if any(
10521058
str(symbol) in reaction_ids
10531059
for symbol in self.flux_vector[reaction_index].free_symbols

0 commit comments

Comments
 (0)