Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s
18 lines
794 B
Python
18 lines
794 B
Python
"""Regression test for compare_win_rates when comparisons list is empty."""
|
|
import numpy as np
|
|
import pandas as pd
|
|
from elo_rating import EloRatingSystem
|
|
from leaderboard import compare_win_rates
|
|
|
|
|
|
def test_compare_win_rates_empty_has_required_columns():
|
|
"""compare_win_rates must return a DataFrame with required columns when no valid comparisons exist."""
|
|
elo = EloRatingSystem()
|
|
empirical_df = pd.DataFrame(np.nan, index=["model_a", "model_b"], columns=["model_a", "model_b"])
|
|
df_comp = compare_win_rates(elo, empirical_df)
|
|
assert list(df_comp.columns) == ["model_a", "model_b", "empirical", "predicted", "error"]
|
|
assert len(df_comp) == 0
|
|
# Accessing columns on empty result must not raise KeyError
|
|
assert "error" in df_comp
|
|
assert df_comp["error"].empty
|