Skip to content

Commit 2a635ff

Browse files
committed
BooleanFunction to Piecewise
1 parent e93bdb8 commit 2a635ff

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

.github/workflows/test_sbml_semantic_test_suite.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
uses: ./.github/actions/install-apt-dependencies
4646

4747
- run: AMICI_PARALLEL_COMPILE="" ./scripts/installAmiciSource.sh
48+
- run: venv/bin/python -m pip install git+https://github.com/dweindl/sbmlmath.git#egg=sbmlmath
4849
- run: AMICI_PARALLEL_COMPILE="" ./scripts/run-SBMLTestsuite.sh ${{ matrix.cases }}
4950

5051
- name: "Upload artifact: SBML semantic test suite results"

python/sdist/amici/sbml_import.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from sbmlmath import SBMLMathMLParser, TimeSymbol, CSymbol
2525
import numpy as np
2626
import sympy as sp
27-
from sympy.logic.boolalg import BooleanFalse, BooleanTrue
27+
from sympy.logic.boolalg import BooleanFalse, BooleanTrue, BooleanFunction
2828

2929
from . import has_clibs
3030
from .de_model import DEModel
@@ -2904,6 +2904,7 @@ def _sympy_from_sbml_math(
29042904
definition_url="http://www.sbml.org/sbml/symbols/avogadro",
29052905
)
29062906
expr = expr.subs(avogadro, sp.Float(float(avogadro)))
2907+
29072908
# replace other symbols, e.g. for handling hardcoded parameters
29082909
expr = expr.subs(
29092910
{
@@ -2929,6 +2930,12 @@ def _sympy_from_sbml_math(
29292930
expr = expr.evalf()
29302931
_check_unsupported_functions_sbml(expr, expression_type=ele_name)
29312932

2933+
# boolean to numeric piecewise
2934+
if isinstance(expr, BooleanFunction):
2935+
from sbmlmath.mathml_parser import _bool2num
2936+
2937+
expr = _bool2num(expr)
2938+
29322939
# piecewise to heavisides
29332940
if piecewise_to_heaviside:
29342941
try:

0 commit comments

Comments
 (0)