"""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