Skip to content

Commit

Permalink
Missed a detail in regex for loading
Browse files Browse the repository at this point in the history
  • Loading branch information
zwergziege committed Mar 19, 2024
1 parent 14738e1 commit b419a65
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion aalpy/utils/FileHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def load_automaton_from_file(path, automaton_type, compute_prefixes=False):
elif '__start0' not in line and 'label' in line and '->' not in line:
state_id = line.split('[')[0].strip()
match = re.search(label_pattern, line)
label = match.group(1)
label = _strip_label(match.group(1))
_process_node_label_prime(state_id, label, line, node_label_dict, nodeType, automaton_type)
# transitions
elif '->' in line:
Expand Down
24 changes: 12 additions & 12 deletions tests/test_file_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ class TestFileHandler(unittest.TestCase):

def test_saving_loading(self):
try:
dfa = get_Angluin_dfa()
mealy = load_automaton_from_file('../DotModels/Angluin_Mealy.dot', automaton_type='mealy')
moore = load_automaton_from_file('../DotModels/Angluin_Moore.dot', automaton_type='moore')
onfsm = get_benchmark_ONFSM()
mdp = get_small_pomdp()
smm = get_faulty_coffee_machine_SMM()
mc = generate_random_markov_chain(num_states=10)

models = [dfa, mealy, moore, onfsm, mc, mdp, smm]
types = ['dfa', 'mealy', 'moore', 'onfsm', 'mc', 'mdp', 'smm']

for model, type in zip(models, types):
type_model_pairs = [
("dfa", get_Angluin_dfa()),
("mealy", load_automaton_from_file('../DotModels/Angluin_Mealy.dot', automaton_type='mealy')),
("moore", load_automaton_from_file('../DotModels/Angluin_Moore.dot', automaton_type='moore')),
("onfsm", get_benchmark_ONFSM()),
("mdp", get_small_pomdp()),
("mdp", load_automaton_from_file('../DotModels/MDPs/first_grid.dot', automaton_type='mdp')),
("smm", get_faulty_coffee_machine_SMM()),
("mc", generate_random_markov_chain(num_states=10)),
]

for type, model in type_model_pairs:
model.save()
print(model)
loaded_model = load_automaton_from_file('LearnedModel.dot', type)
Expand Down

0 comments on commit b419a65

Please sign in to comment.