summaryrefslogtreecommitdiff
path: root/monkey
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2016-01-10 15:14:28 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2016-01-10 15:14:28 +0100
commitf740bd1d0617b35bad55b1212598de6fd98e683b (patch)
treec8608616b04342e97280e6840c4705245312df74 /monkey
parentbedda51c8d4acb81ff4af2f8d79c1c4b3ba0ebf1 (diff)
Avoid a potential division by zero
Diffstat (limited to 'monkey')
-rw-r--r--monkey/edits.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/monkey/edits.py b/monkey/edits.py
index 4774c9a..1863d73 100644
--- a/monkey/edits.py
+++ b/monkey/edits.py
@@ -169,9 +169,10 @@ def get_edits_from_solutions(solutions, test):
edits = new_edits
# Tweak the edit distribution to improve search.
- avg_p = avg(edits.values())
- for edit, p in edits.items():
- edits[edit] = logistic(p, k=3, x_0=avg_p)
+ if edits:
+ avg_p = avg(edits.values())
+ for edit, p in edits.items():
+ edits[edit] = logistic(p, k=3, x_0=avg_p)
return edits, submissions, queries
@@ -236,7 +237,7 @@ if __name__ == '__main__':
if code_key in test_results[pid]:
return test_results[pid][code_key]
- aux_code = '\n' + solutions_for_problems('prolog', dependencies) + '\n' + facts
+ aux_code = '\n' + solutions_for_problems(problem.language, dependencies) + '\n' + facts
correct, hints = problem_module.test(code, aux_code)
test_results[pid][code_key] = correct
return correct