Skip to content

Commit 6cee2e7

Browse files
committed
fixed incorrect condition for graping
1 parent 67d30c9 commit 6cee2e7

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

grape/automaton/loop_manager.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Generator
44

55
from grape import types
6+
from grape.automaton.spec_manager import is_specialized
67
from grape.automaton.tree_automaton import DFTA
78
from grape.dsl import DSL
89
from grape.program import Function, Primitive, Program, Variable
@@ -103,7 +104,7 @@ def __convert_automaton__(dfta: DFTA[str, str]) -> DFTA[str, Program]:
103104

104105
def __get_largest_merges__(
105106
state: str,
106-
dfta: DFTA[str, str | Program],
107+
dfta: DFTA[str, str],
107108
state_to_letter: dict[str, tuple[str, bool]],
108109
state_to_size: dict[str, int],
109110
merge_memory: dict[(str, str), bool],
@@ -131,7 +132,7 @@ def __get_largest_merges__(
131132

132133
def __all_sub_args__(
133134
combi: tuple[str, ...],
134-
dfta: DFTA[str, str | Program],
135+
dfta: DFTA[str, str],
135136
state_to_letter: dict[str, tuple[str, bool]],
136137
state_to_size: dict[str, int],
137138
merge_memory: dict[(str, str), bool],
@@ -157,7 +158,7 @@ def __all_sub_args__(
157158

158159

159160
def add_loops(
160-
dfta: DFTA[str, Program | str],
161+
dfta: DFTA[str, str],
161162
dsl: DSL,
162163
algorithm: LoopingAlgorithm = LoopingAlgorithm.OBSERVATIONAL_EQUIVALENCE,
163164
) -> DFTA[str, Program]:
@@ -166,6 +167,8 @@ def add_loops(
166167
"""
167168
if dfta.is_unbounded():
168169
raise ValueError("automaton is already looping: cannot add loops!")
170+
elif not is_specialized(dfta):
171+
raise ValueError("automaton is not specialized: cannot add loops!")
169172
else:
170173
match algorithm:
171174
case LoopingAlgorithm.OBSERVATIONAL_EQUIVALENCE:
@@ -183,7 +186,7 @@ def is_allowed(
183186
states_by_types: dict[str, list[str]],
184187
) -> bool:
185188
return all(
186-
(P, sub_args) not in new_dfta
189+
(P, sub_args) in new_dfta
187190
for sub_args in __all_sub_args__(
188191
combi,
189192
dfta,

0 commit comments

Comments
 (0)