Skip to content

Commit 6b1aec1

Browse files
committed
Remove duplicate function for compatible states check
1 parent 0f3c79b commit 6b1aec1

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

aalpy/learning_algs/deterministic_passive/ClassicRPNI.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def run_rpni(self):
2727
merged = False
2828

2929
for red_state in red:
30-
if not self._compatible_states(red_state, lex_min_blue):
30+
if not red_state.compatible_outputs(lex_min_blue):
3131
continue
3232
merge_candidate = self._merge(red_state, lex_min_blue, copy_nodes=True)
3333
if self._compatible(merge_candidate):
@@ -62,20 +62,6 @@ def _compatible(self, root_node):
6262
return False
6363
return True
6464

65-
# TODO this function is a duplicate
66-
def _compatible_states(self, red_node, blue_node):
67-
"""
68-
Only allow merging of states that have same output(s).
69-
"""
70-
if self.automaton_type != 'mealy':
71-
# None is compatible with everything
72-
return red_node.output == blue_node.output or red_node.output is None or blue_node.output is None
73-
else:
74-
for common_i in set(red_node.output.keys()).intersection(blue_node.output.keys()):
75-
if red_node.output[common_i] != blue_node.output[common_i]:
76-
return False
77-
return True
78-
7965
def _merge(self, red_node, lex_min_blue, copy_nodes=False):
8066
"""
8167
Merge two states and return the root node of resulting model.

aalpy/learning_algs/deterministic_passive/rpni_helper_functions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def __hash__(self):
3434
return id(self) # TODO This is a hack
3535

3636
def compatible_outputs(self, other):
37+
"""
38+
Only allow merging of states that have same output(s).
39+
"""
3740
# None is compatible with everything
3841
if self.type != 'mealy':
3942
return self.output == other.output or self.output is None or other.output is None

0 commit comments

Comments
 (0)