(
*,
config: ExperimentConfig,
per_row: list[dict[str, Any]],
errors: list[dict[str, Any]],
summary: dict[str, Any],
)
| 80 | |
| 81 | |
| 82 | def _summarize_exact( |
| 83 | *, |
| 84 | config: ExperimentConfig, |
| 85 | per_row: list[dict[str, Any]], |
| 86 | errors: list[dict[str, Any]], |
| 87 | summary: dict[str, Any], |
| 88 | ) -> dict[str, Any]: |
| 89 | total = len(per_row) |
| 90 | exact_match = sum(1 for row in per_row if row.get("match") is True) |
| 91 | pass_count = sum(1 for row in per_row if row.get("passed") is True) |
| 92 | by_benchmark: dict[str, Any] = {} |
| 93 | |
| 94 | grouped: dict[str, list[dict[str, Any]]] = {} |
| 95 | for row in per_row: |
| 96 | grouped.setdefault(row["benchmark"], []).append(row) |
| 97 | |
| 98 | for benchmark, rows in grouped.items(): |
| 99 | benchmark_total = len(rows) |
| 100 | benchmark_exact = sum(1 for row in rows if row.get("match") is True) |
| 101 | benchmark_pass = sum(1 for row in rows if row.get("passed") is True) |
| 102 | by_benchmark[benchmark] = { |
| 103 | "total": benchmark_total, |
| 104 | "exact_match": benchmark_exact, |
| 105 | "pass_count": benchmark_pass, |
| 106 | "tier_match_accuracy": benchmark_exact / benchmark_total if benchmark_total else 0.0, |
| 107 | "pass_rate": benchmark_pass / benchmark_total if benchmark_total else 0.0, |
| 108 | } |
| 109 | |
| 110 | return { |
| 111 | "name": _config_name(config), |
| 112 | "config": asdict(config), |
| 113 | "changed_dimensions": _changed_dimensions(config), |
| 114 | "samples": total, |
| 115 | "exact_match": exact_match, |
| 116 | "pass_count": pass_count, |
| 117 | "tier_match_accuracy": exact_match / total if total else 0.0, |
| 118 | "pass_rate": pass_count / total if total else 0.0, |
| 119 | "api_errors": len(errors), |
| 120 | "cost_savings_score": summary["section_11"]["cost_savings_score"], |
| 121 | "overall_score_percent": summary["router_accounting"]["overall_score_percent"], |
| 122 | "by_benchmark": _sort_benchmarks(by_benchmark), |
| 123 | } |
| 124 | |
| 125 | |
| 126 | def _attach_delta(result: dict[str, Any], baseline: dict[str, Any]) -> dict[str, Any]: |
no test coverage detected