diff --git a/src/tinymfv/maps.py b/src/tinymfv/maps.py index e31b846..8593c87 100644 --- a/src/tinymfv/maps.py +++ b/src/tinymfv/maps.py @@ -81,12 +81,17 @@ C_BASE, C_HON, C_DIS, C_HUM = "#111111", POS_COL, NEG_COL, "#888888" # instrument's map (research consistency). Keyed by the zone names the caller passes; an unlisted # zone falls back to grey. -- added by Claude ZONE_COLORS = { - "English-Speaking": "#4e79a7", + # macro zones (map default) + "West": "#4e79a7", + "East Asia": "#e15759", + # fine zones (macro=False) + "English-Speaking": "#4e79a7", "Protestant Europe": "#59a14f", "Catholic Europe": "#8cd17d", - "Orthodox": "#b6992d", "Baltic": "#499894", "Confucian": "#e15759", + # shared by both groupings + "Orthodox": "#b6992d", "Latin America": "#f28e2b", "African-Islamic": "#9c755f", "South Asia": "#b07aa1", diff --git a/src/tinymfv/zones.py b/src/tinymfv/zones.py index 658a723..d777afc 100644 --- a/src/tinymfv/zones.py +++ b/src/tinymfv/zones.py @@ -78,6 +78,16 @@ _CANON = { ECONOMIST_OUTLIERS = {"China", "South Korea", "United States", "Great Britain", "Japan", "Nigeria", "Pakistan", "Sweden"} +# Coarser macro-zones for the maps. The nine fine IW zones over-fragment low-dimensional maps: the +# English-speaking world and the European religions (Protestant/Catholic/Baltic) don't separate, so +# they merge into one "West"; "Confucian" reads oddly for Japan/Korea, so it's the plainer "East +# Asia". Fewer, better-separated blobs. -- authored by Claude +IW_MACRO = { + "English-Speaking": "West", "Protestant Europe": "West", "Catholic Europe": "West", + "Baltic": "West", "Orthodox": "Orthodox", "Confucian": "East Asia", + "Latin America": "Latin America", "African-Islamic": "African-Islamic", "South Asia": "South Asia", +} + def zone_of(country: str) -> str | None: """IW zone of a verbatim country string, or None for a known-corrupt row. KeyErrors (fail loud) @@ -86,9 +96,11 @@ def zone_of(country: str) -> str | None: return None if canon is None else IW_ZONE[canon] -def zones_for(countries: list[str]) -> tuple[dict[str, list[str]], set[str]]: +def zones_for(countries: list[str], macro: bool = True) -> tuple[dict[str, list[str]], set[str]]: """Group verbatim country strings by IW zone + the subset to emphasize (Economist outliers). - Known-corrupt rows are dropped with a warning; unrecognised countries KeyError via zone_of.""" + `macro` (default) collapses the nine fine zones to six broader ones (IW_MACRO) so low-dimensional + maps aren't over-fragmented. Known-corrupt rows are dropped with a warning; unrecognised countries + KeyError via zone_of.""" groups: dict[str, list[str]] = {} dropped: list[str] = [] emph: set[str] = set() @@ -97,7 +109,7 @@ def zones_for(countries: list[str]) -> tuple[dict[str, list[str]], set[str]]: if z is None: dropped.append(c) continue - groups.setdefault(z, []).append(c) + groups.setdefault(IW_MACRO[z] if macro else z, []).append(c) if _CANON.get(c, c) in ECONOMIST_OUTLIERS: emph.add(c) if dropped: