Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where we set initials dict to return of initials.update rather than just calling initials.update #268

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mira/metamodel/template_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ def add_template(
)
else:
initials = self.initials or {}
initials = initials.update(initial_mapping or {})
initials.update(initial_mapping or {})
parameters = self.parameters or {}
parameters.update(parameter_mapping or {})
return TemplateModel(
Expand Down
14 changes: 12 additions & 2 deletions tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sympy
from mira.metamodel import ControlledConversion, Concept, NaturalConversion, \
NaturalDegradation, Template, GroupedControlledConversion, \
GroupedControlledProduction, TemplateModel
GroupedControlledProduction, TemplateModel, Initial, Parameter
from mira.metamodel.templates import Config
from mira.dkg.web_client import is_ontological_child_web

Expand Down Expand Up @@ -328,6 +328,8 @@ def test_different_class_refinement():


def test_extend_template_model():
from copy import deepcopy as _d

s = Concept(name='s')
o = Concept(name='o')
c1 = Concept(name='c1')
Expand All @@ -340,5 +342,13 @@ def test_extend_template_model():
tm = TemplateModel(templates=[t1, t2, t3], parameters={}, initials={})

t4 = ControlledConversion(subject=c1, outcome=o, controller=c1)
tm2 = tm.add_template(template=t4)

test_initial = Initial(concept=_d(s), expression=sympy.Symbol('s'))
test_param = Parameter(name='test_param')
initial_mapping = {'test_initial': test_initial}
parameter_mapping = {'test_param': test_param}

tm2 = tm.add_template(template=t4,
initial_mapping=initial_mapping,
parameter_mapping=parameter_mapping)
assert tm2.templates == [t1, t2, t3, t4]
Loading