Skip to content

Commit fd4f9ae

Browse files
authored
Merge pull request #62 from MaxiSchwindler/master
Fix to_state_setup() with unreachable states
2 parents e295912 + d8d0261 commit fd4f9ae

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

aalpy/automata/Dfa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def to_state_setup(self):
5757
# ensure prefixes are computed
5858
self.compute_prefixes()
5959

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

aalpy/automata/MealyMachine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def to_state_setup(self):
4242
# ensure prefixes are computed
4343
self.compute_prefixes()
4444

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

aalpy/automata/MooreMachine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def to_state_setup(self):
5454
# ensure prefixes are computed
5555
self.compute_prefixes()
5656

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

aalpy/automata/Vpa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def to_state_setup(self):
156156
# ensure prefixes are computed
157157
# self.compute_prefixes()
158158

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

0 commit comments

Comments
 (0)