From a168403d683deb8bd5530bf2e048952dcd3033ee Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 18 Dec 2024 12:38:40 -0800 Subject: [PATCH] fix: Correctly extract language and testcase from results --- benchmark/problem_stats.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/benchmark/problem_stats.py b/benchmark/problem_stats.py index 6dadb9ea4..1e8571790 100755 --- a/benchmark/problem_stats.py +++ b/benchmark/problem_stats.py @@ -30,8 +30,9 @@ def load_results(dirname): try: results = json.loads(fname.read_text()) # Add language info to results - lang = fname.parts[-4] # Get language from path + lang = fname.parts[-5] # Get language from path results["language"] = lang + dump(results) all_results.append(results) except json.JSONDecodeError: print(f"Failed to parse {fname}") @@ -87,7 +88,7 @@ def analyze_exercise_solutions(dirs=None, topn=None): if results: for result in results: try: - all_exercises.add(result["testcase"]) + all_exercises.add(result["language"] + "/" + result["testcase"]) except KeyError: print(f"Warning: Missing testcase in {dirname}") @@ -100,7 +101,11 @@ def analyze_exercise_solutions(dirs=None, topn=None): testcase = result.get("testcase") if not testcase: continue + lang = result.get("language") + if not lang: + continue + testcase = f"{lang}/{testcase}" # Consider it solved if the last test attempt passed tests_outcomes = result.get("tests_outcomes", []) if tests_outcomes and tests_outcomes[-1]: