Coverage¶
The country × feature × wave coverage/readiness model behind
ll.coverage() and the make matrix CLI.
coverage_matrix ¶
Country × Feature × Wave coverage / readiness model.
The importable core behind bench/matrix.py and the ll.coverage() reader.
Composes existing machinery — it does not reinvent sanity checks or the
declared matrix:
- axes / declared coverage -> :mod:
lsms_library.catalog+Country.waves+Wave.data_scheme(config only; no builds, no auth); - per-wave readiness -> :func:
diagnostics.load_featurebuilds the country-level table once; we slice it on thetindex level and run the existing :func:diagnostics.is_this_feature_saneper wave.
See .coder/charter-coverage-matrix.md and .coder/ledger/coverage-matrix.md.
Tier ladder (worst→best; each derived from existing machinery only):
========== ===========================================================
tier meaning
========== ===========================================================
n/a no per-wave readiness applies (country-level-only feature, or
the built table has no t axis)
absent feature applies to the country but its source is not declared
for this wave (feature ∉ Wave.data_scheme ∪ derived)
declared source present for the wave; readiness not assessed
(coverage-only run)
dropped source declared for the wave but the wave is missing / empty in
the built table (the silent-drop bug class, e.g. Iraq #532)
broken the country-level build raised, or the whole feature is empty
builds wave slice is non-empty but SanityReport.ok is False
sane wave slice is non-empty and SanityReport.ok is True
blessed sane and listed in the git-tracked blessing file
========== ===========================================================
coverage ¶
coverage(refresh: bool | str = False, *, countries=None, features=None, snapshot: Path | None = None) -> pd.DataFrame
Return the country × feature × wave status table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
refresh
|
bool | str
|
|
False
|
countries
|
list[str] | None
|
Restrict a refresh; ignored when reading the snapshot. |
None
|
features
|
list[str] | None
|
Restrict a refresh; ignored when reading the snapshot. |
None
|
snapshot
|
Path | None
|
Override the snapshot location (env |
None
|
Returns:
| Type | Description |
|---|---|
pandas.DataFrame (columns: country, feature, wave, tier, coverage, n_rows, detail)
|
|
build_matrix ¶
build_matrix(countries=None, features=None, *, readiness=True, blessed=None, log=lambda _m: None) -> pd.DataFrame
Build the full (country × feature × wave) status table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
countries
|
list[str] | None
|
Restrict the sweep; |
None
|
features
|
list[str] | None
|
Restrict the sweep; |
None
|
readiness
|
bool
|
If |
True
|
blessed
|
set | None
|
Blessed-cell set; defaults to :func: |
None
|
log
|
callable
|
Progress sink (one line per country). |
lambda _m: None
|
grade_feature ¶
grade_feature(country_name, feature, waves, co, env, *, avail_by_wave=None, blessed=frozenset(), readiness=True) -> list[dict]
Per-wave cells for one (country, feature).
Builds the country-level table at most once (readiness=True) and grades
each wave by slicing on t and reusing is_this_feature_sane.
avail_by_wave maps wave -> available-feature set; :func:build_matrix
precomputes it once per country (it is identical across that country's
features). When None we compute it here, keeping the function
self-contained for tests / one-off calls.
grade_country_level ¶
Grade a country-level-only feature (panel_ids / updated_ids): wave=None.
load_blessed ¶
Return the git-tracked set of blessed (country, feature, wave) cells.
CSV with header country,feature,wave (wave blank for country-level
features). Missing file → empty set.
save_snapshot ¶
Write the status table to the git-tracked snapshot CSV.
default_snapshot_path ¶
Resolve the status snapshot CSV (env → CWD → repo root).