Skip to content

Commit

Permalink
Handle special rate laws better
Browse files Browse the repository at this point in the history
  • Loading branch information
bgyori committed Jul 12, 2023
1 parent f2e8abc commit 48478ed
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mira/metamodel/template_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,16 @@ def get_parameters_from_rate_law(self, rate_law) -> Set[str]:
:
A set of parameter names (as strings)
"""
if not rate_law:
if rate_law is None:
return set()
params = set()
if isinstance(rate_law, sympy.Symbol):
if rate_law.name in self.parameters:
# add the string name to the set
params.add(rate_law.name)
elif not isinstance(rate_law, sympy.Expr):
# There are many sympy classes that have args that can occur here
# so it's better to check for the presence of args
elif not hasattr(rate_law, 'args'):
raise ValueError(f"Rate law is of invalid type {type(rate_law)}: {rate_law}")
else:
for arg in rate_law.args:
Expand Down

0 comments on commit 48478ed

Please sign in to comment.