diff --git a/src/modeci_mdf/execution_engine.py b/src/modeci_mdf/execution_engine.py index 50558b49..e5429757 100644 --- a/src/modeci_mdf/execution_engine.py +++ b/src/modeci_mdf/execution_engine.py @@ -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, @@ -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... diff --git a/src/modeci_mdf/interfaces/graphviz/exporter.py b/src/modeci_mdf/interfaces/graphviz/exporter.py index 770b45d2..b928e0bc 100644 --- a/src/modeci_mdf/interfaces/graphviz/exporter.py +++ b/src/modeci_mdf/interfaces/graphviz/exporter.py @@ -352,12 +352,20 @@ def mdf_to_graphviz( p.time_derivative, node ) for cond in p.conditions: - test = cond.test.replace(">", ">").replace("<", "<") + 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(">", ">").replace("<", "<") v += "
{}: 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 += "{}{} = {}".format( format_label(" "),