From f740bd1d0617b35bad55b1212598de6fd98e683b Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sun, 10 Jan 2016 15:14:28 +0100 Subject: Avoid a potential division by zero --- monkey/edits.py | 9 +++++---- 1 file 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 -- cgit v1.2.1