Skip to content

Commit

Permalink
Fix to_state_setup() with unreachable states
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilian Rindler committed Oct 21, 2024
1 parent 9e9edcd commit cc30abb
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion aalpy/automata/Dfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def to_state_setup(self):
# ensure prefixes are computed
self.compute_prefixes()

sorted_states = sorted(self.states, key=lambda x: len(x.prefix))
sorted_states = sorted(self.states, key=lambda x: len(x.prefix) if x.prefix is not None else len(self.states))
for s in sorted_states:
state_setup_dict[s.state_id] = (s.is_accepting, {k: v.state_id for k, v in s.transitions.items()})

Expand Down
2 changes: 1 addition & 1 deletion aalpy/automata/MealyMachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def to_state_setup(self):
# ensure prefixes are computed
self.compute_prefixes()

sorted_states = sorted(self.states, key=lambda x: len(x.prefix))
sorted_states = sorted(self.states, key=lambda x: len(x.prefix) if x.prefix is not None else len(self.states))
for s in sorted_states:
state_setup_dict[s.state_id] = {k: (s.output_fun[k], v.state_id) for k, v in s.transitions.items()}

Expand Down
2 changes: 1 addition & 1 deletion aalpy/automata/MooreMachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def to_state_setup(self):
# ensure prefixes are computed
self.compute_prefixes()

sorted_states = sorted(self.states, key=lambda x: len(x.prefix))
sorted_states = sorted(self.states, key=lambda x: len(x.prefix) if x.prefix is not None else len(self.states))
for s in sorted_states:
state_setup_dict[s.state_id] = (s.output, {k: v.state_id for k, v in s.transitions.items()})

Expand Down
2 changes: 1 addition & 1 deletion aalpy/automata/Vpa.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def to_state_setup(self):
# ensure prefixes are computed
# self.compute_prefixes()

sorted_states = sorted(self.states, key=lambda x: len(x.prefix))
sorted_states = sorted(self.states, key=lambda x: len(x.prefix) if x.prefix is not None else len(self.states))
for s in sorted_states:
state_setup_dict[s.state_id] = (
s.is_accepting, {k: (v.target_state.state_id, v.action) for k, v in s.transitions.items()})
Expand Down

0 comments on commit cc30abb

Please sign in to comment.