🐛 Fix "rest of the world" introduced in 2023

This commit is contained in:
2025-11-05 16:17:23 +01:00
parent 4ff6f4841c
commit 80051b7dd7
2 changed files with 17 additions and 6 deletions

View File

@@ -60,7 +60,7 @@ def sort_dict[A, B](d: dict[A, B], *, reverse: bool = True) -> dict[A, B]:
@app.command()
def run(jury_path: Path = "jury.txt", participating_countries: int = 37) -> None: # pyright: ignore [reportArgumentType]
def run(jury_path: Path = "jury.txt", participating_countries: int = 37, rest_of_world_vote: bool = True) -> None: # pyright: ignore [reportArgumentType]
"""Run the ESC jury and televoting scoring prediction system."""
jury_file = Path(jury_path)
if not jury_file.exists():
@@ -118,10 +118,11 @@ def run(jury_path: Path = "jury.txt", participating_countries: int = 37) -> None
for _ in range(20):
time.sleep(0.1)
# Compute the (participating_countries + 1)x58 total and subtract the N-1 sum
total_available = sum((12, 10, 8, 7, 6, 5, 4, 3, 2, 1)) * (
participating_countries + 1
) # N-1 televoting + 1 rest of the world
# Compute the total available points
# Each voting country gives 58 points total (12+10+8+7+6+5+4+3+2+1)
# From 2023 onwards, there's also a "rest of the world" televote (+1)
voting_countries = participating_countries + (1 if rest_of_world_vote else 0)
total_available = sum((12, 10, 8, 7, 6, 5, 4, 3, 2, 1)) * voting_countries
sum_entered = sum(televoting_data.values())
missing = set(jury_scores) - set(televoting_data)
country_to_predict = missing.pop()

View File

@@ -22,6 +22,9 @@ DATASET_PATH = DATASET_BASE / "senior"
YEARS_TO_TEST = list(range(2016, 2026))
# Rest of world televote was introduced in Eurovision 2023
REST_OF_WORLD_VOTE_YEAR = 2023
class ESCData(TypedDict):
"""TypedDict for ESC data."""
@@ -161,10 +164,17 @@ def test_esc_grand_final(year: int, data: ESCData) -> None:
inputs.append(str(televote_scores[country])) # noqa: PERF401
inputs.append("y") # to confirm the winner
# Determine if rest of world vote should be included based on the year
rest_of_world_vote = year >= REST_OF_WORLD_VOTE_YEAR
runner = CliRunner()
result = runner.invoke(
app,
["--jury-path", f.name, "--participating-countries", str(participating_countries)],
[
"--jury-path", f.name,
"--participating-countries", str(participating_countries),
"--rest-of-world-vote" if rest_of_world_vote else "--no-rest-of-world-vote",
],
input="\n".join(inputs),
)