Skip to content

Commit

Permalink
rename parameters in stratify and other MIRA changes (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwdchang authored Aug 7, 2024
1 parent 566c117 commit aa3188d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sympy
def replace_rate_law_sympy(model, template_name, new_rate_law):
"""Replace the rate law of transition. The new rate law passed in will be a sympy.Expr object
Expand All @@ -8,8 +9,6 @@ def replace_rate_law_sympy(model, template_name, new_rate_law):
typically the name of the transition
new_rate_law :
The new rate law to replace the existing rate law with
local_dict :
A dictionary of local variables to use when parsing.
Returns
-------
Expand All @@ -18,9 +17,13 @@ def replace_rate_law_sympy(model, template_name, new_rate_law):
"""
assert isinstance(model, TemplateModel)
tm = model
local_dict = { key:sympy.Symbol(key) for key, _value in tm.parameters.items() }
for k, v in tm.get_concepts_name_map().items():
local_dict[k] = sympy.Symbol(k)

for template in tm.templates:
if template.name == template_name:
template.set_rate_law(new_rate_law, local_dict=None)
template.set_rate_law(new_rate_law, local_dict=local_dict)
return tm

model = replace_rate_law_sympy(model, "{{ template_name }}", "{{ new_rate_law }}")
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
cartesian_control={{ cartesian_control|default(False) }},
modify_names={{ modify_names|default(True) }},
concepts_to_stratify={{ concepts_to_stratify|default(None) }}, #If none given, will stratify all concepts.
params_to_stratify= {{ params_to_stratify|default(None) }} #If none given, will stratify all parameters.
)
params_to_stratify= {{ params_to_stratify|default(None) }}, #If none given, will stratify all parameters.
param_renaming_uses_strata_names = True
)

0 comments on commit aa3188d

Please sign in to comment.