From f7c39d3e08ae1a9fe03d87e725fb8568f11be7a3 Mon Sep 17 00:00:00 2001 From: chenzimin Date: Tue, 20 Jun 2023 11:02:04 +0200 Subject: [PATCH] Update sandbox.py Fixes issue #3. The problem is that the default value of cflags and return_if_acc_below are not handled properly in the run_cpp_code_on_inputs function. --- src/codenet_eval/sandbox.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/codenet_eval/sandbox.py b/src/codenet_eval/sandbox.py index cd8d5fe..c250d6c 100644 --- a/src/codenet_eval/sandbox.py +++ b/src/codenet_eval/sandbox.py @@ -328,6 +328,10 @@ def run_cpp_code_on_inputs( """ + # Setting cflags to the default value if cflags is None, else calling compile_cpp_code will fail. + if cflags is None: + cflags = "--std=c++17 -O1" + try: binary_output_path = compile_cpp_code(code_path, cflags=cflags) except Exception as e: @@ -369,7 +373,7 @@ def run_cpp_code_on_inputs( times_millisec.append(time_taken * 1000) if ground_truths is not None: acc = get_accuracy(output, ground_truths[test_case_idx]) - if acc < return_if_acc_below: + if return_if_acc_below is not None and acc < return_if_acc_below: if remove_code_after_run: os.remove(binary_output_path) logging.info(f"Accuracy {acc} below {return_if_acc_below}. Returning.")