Skip to content

Commit

Permalink
Temp partial fix for parametercondition issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Aug 21, 2024
1 parent 9dc3dce commit 31b626a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
17 changes: 14 additions & 3 deletions src/modeci_mdf/execution_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,15 +586,26 @@ def evaluate(

if len(self.parameter.conditions) > 0:
for condition in self.parameter.conditions:

test = (
condition.test if hasattr(condition, "test") else condition["test"]
)
value = (
condition.value
if hasattr(condition, "value")
else condition["value"]
)
cond_id = condition.id if hasattr(condition, "id") else condition["id"]

cond_mask = evaluate_expr(
condition.test,
test,
parameters,
verbose=False,
array_format=array_format,
)

val_if_true = evaluate_expr(
condition.value,
value,
parameters,
verbose=False,
array_format=array_format,
Expand All @@ -603,7 +614,7 @@ def evaluate(
if self.verbose:
print(
" --- Condition: %s: %s = %s: true? %s"
% (condition.id, condition.test, val_if_true, cond_mask)
% (cond_id, test, val_if_true, cond_mask)
)

# e.g. if the parameter value is set only by a set of conditions...
Expand Down
14 changes: 11 additions & 3 deletions src/modeci_mdf/interfaces/graphviz/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,20 @@ def mdf_to_graphviz(
p.time_derivative, node
)
for cond in p.conditions:
test = cond.test.replace(">", "&gt;").replace("<", "&lt;")
cond_test = (
cond.test if hasattr(cond, "test") else cond["test"]
)
cond_value = (
cond.value if hasattr(cond, "value") else cond["value"]
)
cond_id = cond.id if hasattr(cond, "id") else cond["id"]

test = cond_test.replace(">", "&gt;").replace("<", "&lt;")
v += "<br/><i>{}: </i>IF {} THEN {}={}".format(
cond.id,
cond_id,
match_in_expr(test, node),
format_param(p.id),
match_in_expr(cond.value, node),
match_in_expr(cond_value, node),
)
info += "<tr><td>{}{} = {}</td></tr>".format(
format_label(" "),
Expand Down

0 comments on commit 31b626a

Please sign in to comment.