diff options
-rwxr-xr-x | monkey/monkey.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/monkey/monkey.py b/monkey/monkey.py index b67f7fe..d17d9f1 100755 --- a/monkey/monkey.py +++ b/monkey/monkey.py @@ -22,10 +22,10 @@ def fix(name, code, edits, program_lines, aux_code='', timeout=30, debug=False): # Generate states that can be reached from the given program with one edit. # Program code is given as a list of [lines], where each line is a list of # tokens. Rule ranges are given in [rules] (see prolog.util.decompose). - def step(lines, rules, prev=None): + def step(lines, rules, path=None): # Apply edits in order from top to bottom; skip lines with index lower # than last step. - start_line = prev[1] if prev else 0 + start_line = path[-1][1] if path else 0 for start, end in rules: rule_lines = lines[start:end] @@ -166,8 +166,7 @@ def fix(name, code, edits, program_lines, aux_code='', timeout=30, debug=False): n_tested += 1 # Otherwise generate new solutions. - prev_step = path[-1] if path else None - for new_lines, new_rules, new_step, new_cost in step(lines, rules, prev_step): + for new_lines, new_rules, new_step, new_cost in step(lines, rules, path): new_path_cost = path_cost * new_cost if new_path_cost < 0.01: continue |