mirror of
https://github.com/Paillat-dev/esc-dramatic-unpause.git
synced 2026-01-02 09:16:21 +00:00
🐛 Fix "rest of the world" introduced in 2023
This commit is contained in:
@@ -60,7 +60,7 @@ def sort_dict[A, B](d: dict[A, B], *, reverse: bool = True) -> dict[A, B]:
|
|||||||
|
|
||||||
|
|
||||||
@app.command()
|
@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."""
|
"""Run the ESC jury and televoting scoring prediction system."""
|
||||||
jury_file = Path(jury_path)
|
jury_file = Path(jury_path)
|
||||||
if not jury_file.exists():
|
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):
|
for _ in range(20):
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
# Compute the (participating_countries + 1)x58 total and subtract the N-1 sum
|
# Compute the total available points
|
||||||
total_available = sum((12, 10, 8, 7, 6, 5, 4, 3, 2, 1)) * (
|
# Each voting country gives 58 points total (12+10+8+7+6+5+4+3+2+1)
|
||||||
participating_countries + 1
|
# From 2023 onwards, there's also a "rest of the world" televote (+1)
|
||||||
) # N-1 televoting + 1 rest of the world
|
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())
|
sum_entered = sum(televoting_data.values())
|
||||||
missing = set(jury_scores) - set(televoting_data)
|
missing = set(jury_scores) - set(televoting_data)
|
||||||
country_to_predict = missing.pop()
|
country_to_predict = missing.pop()
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ DATASET_PATH = DATASET_BASE / "senior"
|
|||||||
|
|
||||||
YEARS_TO_TEST = list(range(2016, 2026))
|
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):
|
class ESCData(TypedDict):
|
||||||
"""TypedDict for ESC data."""
|
"""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(str(televote_scores[country])) # noqa: PERF401
|
||||||
inputs.append("y") # to confirm the winner
|
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()
|
runner = CliRunner()
|
||||||
result = runner.invoke(
|
result = runner.invoke(
|
||||||
app,
|
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),
|
input="\n".join(inputs),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user