Spaces:
Running on T4
Running on T4
File size: 1,002 Bytes
ae2c68f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | """Small lookups shared by several modules: mode and focus labels, score tones, the drill catalog."""
from collections.abc import Iterable
from functools import cache
DISCIPLINES = {"h": "hitting", "p": "pitching"} # session mode -> ai_coach drill discipline
FOCUS_LABEL = {"h": "Hitting", "p": "Pitching", "both": "Both"} # coach focus -> display label
TONE_GREEN_MIN = 80 # overall score at or above: "g"; at or above TONE_YELLOW_MIN: "y"; below: "r"
TONE_YELLOW_MIN = 60
@cache
def drill_catalog() -> dict[str, dict]:
"""ai_coach catalog drills by id."""
from ai_coach.knowledge import all_drills
return {d["id"]: d for d in all_drills()}
def tone(score: int | None) -> str:
if score is None:
return "y"
return "g" if score >= TONE_GREEN_MIN else "y" if score >= TONE_YELLOW_MIN else "r"
def tone_counts(scores: Iterable[int]) -> dict[str, int]:
counts = dict.fromkeys("gyr", 0)
for score in scores:
counts[tone(score)] += 1
return counts
|