From 33f8ee41766a24df7b2755a09d1554342394ed93 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 25 Feb 2015 17:00:14 +0100 Subject: Pass the entire current path to monkey.fix.step Only the last step is used currently. --- monkey/monkey.py | 7 +++---- 1 file 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 -- cgit v1.2.1