MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / write_latex_table_plain

Function write_latex_table_plain

codeclash/analysis/metrics/elo.py:1470–1543  ·  view source on GitHub ↗

Write LaTeX table with plain ELO scores and uncertainties (no bar charts). Args: results: Dictionary mapping game name to fit results output_dir: Directory to save the LaTeX file

(results: dict[str, dict], output_dir: Path)

Source from the content-addressed store, hash-verified

1468
1469 for display_name, key in metrics:
1470 nonparam_val = nonparam.get(key, float("nan"))
1471 param_val = param.get(key, float("nan"))
1472 lines.append(rf"{display_name} & {nonparam_val:.3f} & {param_val:.3f} \\")
1473
1474 lines.append(r"\bottomrule")
1475 lines.append(r"\end{tabular}")
1476
1477 output_file.write_text("\n".join(lines) + "\n")
1478 logger.info(f"Saved bootstrap metrics table: {output_file}")
1479
1480
1481def write_latex_table_plain(results: dict[str, dict], output_dir: Path) -> None:
1482 """Write LaTeX table with plain ELO scores and uncertainties (no bar charts).
1483
1484 Args:
1485 results: Dictionary mapping game name to fit results
1486 output_dir: Directory to save the LaTeX file
1487 """
1488 output_dir.mkdir(parents=True, exist_ok=True)
1489 output_file = output_dir / "elo_table_plain.tex"
1490
1491 single_arena_games = ["BattleSnake", "CoreWar", "Halite", "HuskyBench", "RoboCode", "RobotRumble"]
1492 games_in_table = [g for g in single_arena_games if g in results]
1493
1494 if "ALL" not in results:
1495 logger.warning("No 'ALL' game found in results, skipping LaTeX table generation")
1496 return
1497
1498 all_result = results["ALL"]
1499 all_players = all_result["players"]
1500 all_strengths = all_result["strengths"]
1501 all_elos = {p: BradleyTerryFitter.bt_to_elo(s) for p, s in zip(all_players, all_strengths)}
1502 sorted_players = sorted(all_elos.items(), key=lambda x: x[1], reverse=True)
1503
1504 has_uncertainties = "elo_std" in all_result
1505
1506 lines = []
1507 lines.append(r"\begin{table}[t]")
1508 lines.append(r"\centering")
1509 lines.append(r"\caption{ELO ratings" + (" with uncertainties" if has_uncertainties else "") + r"}")
1510 lines.append(r"\label{tab:elo_ratings}")
1511 lines.append(r"\begin{tabular}{l" + "r" * len(games_in_table) + "r}")
1512 lines.append(r"\toprule")
1513
1514 display_names = [g.replace("HuskyBench", "Poker") for g in games_in_table]
1515 header_parts = ["Model"] + display_names + ["All"]
1516 lines.append(" & ".join(header_parts) + r" \\")
1517 lines.append(r"\midrule")
1518
1519 for player, all_elo in sorted_players:
1520 display_name = MODEL_TO_DISPLAY_NAME.get(player, player)
1521 row_parts = [display_name.replace("_", r"\_")]
1522
1523 for game_name in games_in_table:
1524 if game_name in results:
1525 game_result = results[game_name]
1526 if player in game_result["players"]:
1527 idx = game_result["players"].index(player)

Callers 1

elo.pyFile · 0.85

Calls 2

getMethod · 0.80
bt_to_eloMethod · 0.45

Tested by

no test coverage detected