Skip to content

Commit

Permalink
feat: report all langs
Browse files Browse the repository at this point in the history
  • Loading branch information
Co1lin committed Nov 11, 2024
1 parent 97f53c8 commit 09e0e45
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions cweval/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ def _merge_results(self) -> None:
res = json.load(f)
for test_path, test_res in res.items():
# evals/eval_241110_014704/generated_?/core/c/cwe_022_0_c_test.py -> evals/eval_241110_014704/generated_X/core/c/cwe_022_0_c_test.py
for generated_path in self.generated_paths:
if test_path.startswith(generated_path):
break
generated_name = os.path.basename(generated_path)
path_key = test_path.replace(generated_name, f'generated_X')
all_res[path_key] = all_res.get(
Expand Down Expand Up @@ -184,7 +181,7 @@ def _filename_to_lang(self, path: str) -> str:

def report_pass_at_k(self, k: int = 1, lang: str = '', mode: str = '') -> None:
if mode == 'auto':
for lang in ['c', 'py']:
for lang in ['c', 'py', '']:
for k in [1, 3, 10]:
self.report_pass_at_k(k, lang)

Expand Down Expand Up @@ -232,7 +229,7 @@ def report_pass_at_k(self, k: int = 1, lang: str = '', mode: str = '') -> None:
func_secure_rate = sum(func_secure_patks) / num_paths * 100

print(f'=' * 16)
print(f'pass@{k}\t{lang}')
print(f'pass@{k}\t{lang or "all"}')
print(f'functional@{k}\t{functional_rate:.2f}')
print(f'secure@{k}\t{secure_rate:.2f}')
print(f'functional_secure@{k}\t{func_secure_rate:.2f}')
Expand Down

0 comments on commit 09e0e45

Please sign in to comment.