Skip to content

Commit 97a4634

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent e0de536 commit 97a4634

File tree

1 file changed

+60
-17
lines changed

1 file changed

+60
-17
lines changed

scripts/analyze_procmod_bugs.py

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@ def analyze_bugs(repo_id: str) -> Dict[str, Any]:
109109
modifier_name = extract_modifier_name(instance_dir)
110110

111111
# Check if all test result arrays are empty (failed to compile)
112-
if (len(report.get(FAIL_TO_PASS, [])) == 0 and
113-
len(report.get(PASS_TO_PASS, [])) == 0 and
114-
len(report.get(FAIL_TO_FAIL, [])) == 0 and
115-
len(report.get(PASS_TO_FAIL, [])) == 0):
112+
if (
113+
len(report.get(FAIL_TO_PASS, [])) == 0
114+
and len(report.get(PASS_TO_PASS, [])) == 0
115+
and len(report.get(FAIL_TO_FAIL, [])) == 0
116+
and len(report.get(PASS_TO_FAIL, [])) == 0
117+
):
116118
failed_to_compile_bugs[modifier_name] += 1
117119
total_failed_to_compile += 1
118120
continue
@@ -268,7 +270,12 @@ def save_report(analysis: Dict[str, Any], output_file: str) -> None:
268270
print(f"Detailed report saved to: {output_file}")
269271

270272

271-
def plot_bug_distribution(analysis: Dict[str, Any], output_path: str, show_generated_bugs: bool = False, breakdown_generated_bugs: bool = False) -> None:
273+
def plot_bug_distribution(
274+
analysis: Dict[str, Any],
275+
output_path: str,
276+
show_generated_bugs: bool = False,
277+
breakdown_generated_bugs: bool = False,
278+
) -> None:
272279
"""Plot bar chart of bug distribution by modifier type.
273280
274281
Args:
@@ -291,7 +298,9 @@ def plot_bug_distribution(analysis: Dict[str, Any], output_path: str, show_gener
291298
k: {"total": v["validated"], "passed": v["passed"]}
292299
for k, v in modifier_data.items()
293300
}
294-
failed_to_compile_by_modifier = {k: v.get("failed_to_compile", 0) for k, v in modifier_data.items()}
301+
failed_to_compile_by_modifier = {
302+
k: v.get("failed_to_compile", 0) for k, v in modifier_data.items()
303+
}
295304
timeout_by_modifier = {k: v.get("timeout", 0) for k, v in modifier_data.items()}
296305

297306
if not generated_by_modifier:
@@ -327,14 +336,21 @@ def plot_bug_distribution(analysis: Dict[str, Any], output_path: str, show_gener
327336
else:
328337
validated_counts.append(0)
329338
passed_counts.append(0)
330-
failed_to_compile_counts.append(failed_to_compile_by_modifier.get(modifier_key, 0))
339+
failed_to_compile_counts.append(
340+
failed_to_compile_by_modifier.get(modifier_key, 0)
341+
)
331342
timeout_counts.append(timeout_by_modifier.get(modifier_key, 0))
332343

333344
# Filter out modifiers with zero passed bugs
334345
filtered_data = [
335346
(mod, gen, val, pas, ftc, to)
336347
for mod, gen, val, pas, ftc, to in zip(
337-
modifiers_display, generated_counts, validated_counts, passed_counts, failed_to_compile_counts, timeout_counts
348+
modifiers_display,
349+
generated_counts,
350+
validated_counts,
351+
passed_counts,
352+
failed_to_compile_counts,
353+
timeout_counts,
338354
)
339355
if pas > 0
340356
]
@@ -344,9 +360,14 @@ def plot_bug_distribution(analysis: Dict[str, Any], output_path: str, show_gener
344360
return
345361

346362
# Unpack filtered data
347-
modifiers_display, generated_counts, validated_counts, passed_counts, failed_to_compile_counts, timeout_counts = zip(
348-
*filtered_data
349-
)
363+
(
364+
modifiers_display,
365+
generated_counts,
366+
validated_counts,
367+
passed_counts,
368+
failed_to_compile_counts,
369+
timeout_counts,
370+
) = zip(*filtered_data)
350371

351372
# Create figure and axis
352373
fig, ax = plt.subplots(figsize=(14, 8.8))
@@ -372,8 +393,10 @@ def plot_bug_distribution(analysis: Dict[str, Any], output_path: str, show_gener
372393
if breakdown_generated_bugs:
373394
# Calculate positions: failed to compile right above validated, timeout on top
374395
failed_to_compile_bottom = np.array(validated_counts)
375-
timeout_bottom = failed_to_compile_bottom + np.array(failed_to_compile_counts)
376-
396+
timeout_bottom = failed_to_compile_bottom + np.array(
397+
failed_to_compile_counts
398+
)
399+
377400
# Failed to Compile layer (slanted lines) - closer to validated
378401
bars_ftc = ax.bar(
379402
x,
@@ -456,7 +479,15 @@ def plot_bug_distribution(analysis: Dict[str, Any], output_path: str, show_gener
456479

457480
# Add value labels on bars
458481
if show_generated_bugs:
459-
for i, (gen, val, pas, ftc, to) in enumerate(zip(generated_counts, validated_counts, passed_counts, failed_to_compile_counts, timeout_counts)):
482+
for i, (gen, val, pas, ftc, to) in enumerate(
483+
zip(
484+
generated_counts,
485+
validated_counts,
486+
passed_counts,
487+
failed_to_compile_counts,
488+
timeout_counts,
489+
)
490+
):
460491
# Label for generated (at the top of generated bar)
461492
ax.text(
462493
x[i],
@@ -693,7 +724,12 @@ def main():
693724

694725
# Plot bug distribution
695726
plot_output = Path("logs/analysis") / "bug_distribution.png"
696-
plot_bug_distribution(analysis, str(plot_output), args.show_generated_bugs, args.breakdown_generated_bugs)
727+
plot_bug_distribution(
728+
analysis,
729+
str(plot_output),
730+
args.show_generated_bugs,
731+
args.breakdown_generated_bugs,
732+
)
697733
else:
698734
# Analyze all repos
699735
repos = discover_repos()
@@ -756,7 +792,9 @@ def main():
756792
modifier_stats[modifier]["f2p_counts"].extend(data["f2p_counts"])
757793
modifier_stats[modifier]["p2p_counts"].extend(data["p2p_counts"])
758794

759-
for modifier, count in analysis.get("failed_to_compile_by_modifier", {}).items():
795+
for modifier, count in analysis.get(
796+
"failed_to_compile_by_modifier", {}
797+
).items():
760798
modifier_stats[modifier]["failed_to_compile"] += count
761799

762800
for modifier, count in analysis.get("timeout_by_modifier", {}).items():
@@ -804,7 +842,12 @@ def main():
804842

805843
# Plot aggregate bug distribution
806844
plot_output = Path("logs/analysis") / "bug_distribution.png"
807-
plot_bug_distribution(aggregate_data, str(plot_output), args.show_generated_bugs, args.breakdown_generated_bugs)
845+
plot_bug_distribution(
846+
aggregate_data,
847+
str(plot_output),
848+
args.show_generated_bugs,
849+
args.breakdown_generated_bugs,
850+
)
808851

809852

810853
if __name__ == "__main__":

0 commit comments

Comments
 (0)