Skip to content

Commit

Permalink
#330 backend: fix crash when activating continuous variable exception…
Browse files Browse the repository at this point in the history
…s with nested lists
  • Loading branch information
Wolkenfarmer committed Oct 17, 2024
1 parent b8d102a commit eceff0a
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ def _get_values(self, variable_name, future_state):
future_state.vital_signs
)

def _flatten(self, lst):
"""Helper function to recursively flatten a list"""
if isinstance(lst, list):
return tuple(item for sublist in lst for item in self._flatten(sublist))
return (lst,)

def _get_applicable_function(self, variable):
completed_action_uuids = {
str(action.uuid)
Expand All @@ -116,8 +122,12 @@ def _get_applicable_function(self, variable):

for exception in variable.exceptions:
function = exception["function"]
actions = tuple(exception["actions"])
materials = tuple(exception["materials"])
actions = (
self._flatten(exception["actions"]) if exception["actions"] else ()
)
materials = (
self._flatten(exception["materials"]) if exception["materials"] else ()
)

if _check_subset(actions, completed_action_uuids) and _check_subset(
materials, completed_material_uuids
Expand Down

0 comments on commit eceff0a

Please sign in to comment.