summaryrefslogtreecommitdiff
path: root/monkey
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2015-02-25 17:00:14 +0100
committerAleš Smodiš <aless@guru.si>2015-08-11 14:26:02 +0200
commit33f8ee41766a24df7b2755a09d1554342394ed93 (patch)
tree98ffbf0e666dea5158c1cc99c24b348d56bb0576 /monkey
parent2d13584d1599ec75bfd6e9e499379e7fc4987cbb (diff)
Pass the entire current path to monkey.fix.step
Only the last step is used currently.
Diffstat (limited to 'monkey')
-rwxr-xr-xmonkey/monkey.py7
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