From 12c1e264dbb8ec979c17da362ff120a3fa87039c Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 9 Feb 2015 20:38:38 +0100 Subject: Ignore edits after the first correct version --- monkey/edits.py | 7 +++++++ monkey/monkey.py | 1 + 2 files changed, 8 insertions(+) (limited to 'monkey') diff --git a/monkey/edits.py b/monkey/edits.py index bf6560d..8747a6e 100644 --- a/monkey/edits.py +++ b/monkey/edits.py @@ -24,6 +24,7 @@ def edit_graph(actions, debug=False): leaves = {0: nodes[0]} # Current leaf node for each line. rank = 1 # Rank (order / y-position) for the next node. code_next = '' # Program code after applying the current action. + done = False # Set to True on first correct version. # Ensure there is a separate action for each inserted/removed character. expand(actions) @@ -33,11 +34,17 @@ def edit_graph(actions, debug=False): if action.type == 'test': submissions.add(code) + if action.total == action.passed: + done = True elif action.type == 'solve' or action.type == 'solve_all': queries.add(action.query) elif action.type == 'insert' or action.type == 'remove': + # Ignore edits after the first correct version. + if done: + continue + # Number of the changed line. line = code[:action.offset].count('\n') # Current leaf node for this line. diff --git a/monkey/monkey.py b/monkey/monkey.py index 0e622bf..0a934bc 100755 --- a/monkey/monkey.py +++ b/monkey/monkey.py @@ -109,6 +109,7 @@ def fix(name, code, edits, program_lines, aux_code='', timeout=30, debug=False): new_steps = [] i = 0 while i < len(steps): + # Check for successive edits on the same line. if i < len(steps)-1 and \ steps[i][0] in ('add_rule', 'add_subgoal', 'change_line') and \ steps[i+1][0] == 'change_line' and \ -- cgit v1.2.1