Skip to content

Commit

Permalink
Fix Sympy 1.6 Incompatibility (#505)
Browse files Browse the repository at this point in the history
* fix string sympification
* Fix drug_binding macro for sympy 1.6

Co-authored-by: Alex Lubbock <code@alexlubbock.com>
  • Loading branch information
Fabian Fröhlich and alubbock committed Jun 3, 2020
1 parent d112d82 commit f003879
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pysb/bng.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ def parse_bngl_expr(text, *args, **kwargs):
lambda cond, t, f: sympy.Piecewise((t, cond), (f, True))
)
# Check for unsupported constructs.
if expr.has('time'):
if expr.has(sympy.Symbol('time')):
raise ValueError(
"Expressions referencing simulation time are not supported"
)
Expand Down
13 changes: 6 additions & 7 deletions pysb/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@
"""


import inspect
from pysb import *
import pysb.core
from pysb.core import ComponentSet, as_reaction_pattern, as_complex_pattern, MonomerPattern, ComplexPattern
from pysb.core import ComponentSet, as_complex_pattern, MonomerPattern, ComplexPattern
import numbers
import functools
import itertools
from sympy import Piecewise

__all__ = ['equilibrate',
'bind', 'bind_table',
Expand Down Expand Up @@ -953,8 +952,8 @@ def drug_binding(drug, d_site, substrate, s_site, t_action, klist):
Monomer('__t'),
Parameter('__k_t', 1.0),
Observable('t', __t()),
Expression('kf_expr_drug_substrate', kf_drug_substrate*(t > 10)),
Expression('kr_expr_drug_substrate', kr_drug_substrate*(t > 10)),
Expression('kf_expr_drug_substrate', Piecewise((kf_drug_substrate, t > 10), (0, True))),
Expression('kr_expr_drug_substrate', Piecewise((kr_drug_substrate, t > 10), (0, True))),
])
"""
Expand Down Expand Up @@ -992,9 +991,9 @@ def drug_binding(drug, d_site, substrate, s_site, t_action, klist):
raise ValueError("klist must contain Parameters, Expressions, or numbers.")

kf_expr = Expression('kf_expr_{0}_{1}'.format(drug_monomer_name,
substrate_monomer_name), (time_obs > t_action) * k1)
substrate_monomer_name), Piecewise((k1, time_obs > t_action), (0, True)))
kr_expr = Expression('kr_expr_{0}_{1}'.format(drug_monomer_name,
substrate_monomer_name), (time_obs > t_action) * k2)
substrate_monomer_name), Piecewise((k2, time_obs > t_action), (0, True)))
bind_kpars = [kf_expr, kr_expr]

components_added_macro = components_time_obs
Expand Down

0 comments on commit f003879

Please sign in to comment.