summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--monkey/edits.py15
-rwxr-xr-xmonkey/monkey.py2
-rwxr-xr-xmonkey/test.py5
3 files changed, 9 insertions, 13 deletions
diff --git a/monkey/edits.py b/monkey/edits.py
index c625946..e522964 100644
--- a/monkey/edits.py
+++ b/monkey/edits.py
@@ -12,9 +12,9 @@ from .util import get_line, avg, logistic
# representing development history. Each node represents a particular version
# of some line, and each edge represents a "line edit" (contiguous sequence of
# inserts/removes within a single line).
-# Return a list of nodes (first element is the root), and sets of submissions
-# (program versions tested by the user) and queries in this attempt.
-def trace_graph(trace, debug=False):
+# Return a list of nodes with root as the first element. Also return sets of
+# submissions (user-tested program versions) and queries in this attempt.
+def trace_graph(trace):
# Return values.
nodes = [Node([0, 0, ()])] # Node data: rank (Y), line no. (X), and tokens.
submissions = set() # Program versions at 'test' actions.
@@ -211,9 +211,7 @@ def get_edits_from_traces(traces):
for edit, p in edits.items():
edits[edit] = logistic(p, k=3, x_0=avg_p)
- lines = dict(n_leaf)
-
- return edits, lines, submissions, queries
+ return edits, submissions, queries
def classify_edits(edits):
inserts = {}
@@ -240,13 +238,12 @@ if __name__ == '__main__':
from tutor.models import Attempt, Problem
edits = {}
- lines = {}
submissions = {}
queries = {}
for problem in Problem.objects.all():
print(problem.name)
pid = problem.pk
traces = [a.trace for a in Attempt.objects.filter(problem=problem, done=True)]
- edits[pid], lines[pid], submissions[pid], queries[pid] = get_edits_from_traces(traces)
+ edits[pid], submissions[pid], queries[pid] = get_edits_from_traces(traces)
- pickle.dump((edits, lines, submissions, queries), open('edits.pickle', 'wb'))
+ pickle.dump((edits, submissions, queries), open('edits.pickle', 'wb'))
diff --git a/monkey/monkey.py b/monkey/monkey.py
index d17d9f1..3de0a41 100755
--- a/monkey/monkey.py
+++ b/monkey/monkey.py
@@ -13,7 +13,7 @@ from .util import PQueue
# and predicates).
# Return (solution, edits, time spent, #programs checked). If no solution is
# found within [timeout] seconds, solution='' and edits=[].
-def fix(name, code, edits, program_lines, aux_code='', timeout=30, debug=False):
+def fix(name, code, edits, aux_code='', timeout=30, debug=False):
# A dictionary of edits with costs for each edit type (insert, remove or
# change a line). Edits are tuples (before, after), where before and after
# are sequences of tokens. Variable names are normalized to A0, A1, A2,….
diff --git a/monkey/test.py b/monkey/test.py
index 2b01b95..abf9bec 100755
--- a/monkey/test.py
+++ b/monkey/test.py
@@ -34,7 +34,6 @@ attempts = Attempt.objects.filter(problem=problem)
# Load hint database stored in edits.pickle.
edits = tutor_apps.get_app_config('tutor').edits[problem.pk]
-lines = tutor_apps.get_app_config('tutor').lines[problem.pk]
submissions = tutor_apps.get_app_config('tutor').submissions[problem.pk]
queries = tutor_apps.get_app_config('tutor').queries[problem.pk]
@@ -76,7 +75,7 @@ if len(sys.argv) >= 3 and sys.argv[2] == 'test':
print(colored('Analyzing program {0}/{1}…'.format(i+1, len(incorrect)), 'yellow'))
print(indent(compose(*decompose(program)), 2))
- solution, steps, fix_time, n_tested = fix(problem.name, program, edits, lines, aux_code=aux_code, timeout=timeout)
+ solution, steps, fix_time, n_tested = fix(problem.name, program, edits, aux_code=aux_code, timeout=timeout)
if solution:
done.append(program)
print_hint(solution, steps, fix_time, n_tested)
@@ -170,5 +169,5 @@ else:
# Try finding a fix.
print(colored('Analyzing program…', 'yellow'))
- solution, steps, fix_time, n_tested = fix(problem.name, code, edits, lines, aux_code=aux_code, debug=True)
+ solution, steps, fix_time, n_tested = fix(problem.name, code, edits, aux_code=aux_code, debug=True)
print_hint(solution, steps, fix_time, n_tested)