Skip to content

Preserve nullable SPM summaries and JSON - #519

Draft
MaxGhenis wants to merge 1 commit into
mainfrom
max/nullable-spm-poverty-summaries-20260914
Draft

MaxGhenis wants to merge 1 commit into
mainfrom
max/nullable-spm-poverty-summaries-20260914

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #518

When all selected Supplemental Poverty Measure (SPM) statuses are missing or have zero eligible weight, the wrapper now returns a null poverty rate. An observed population with no poor members retains a measured rate of 0.0.

The change preserves nullable rates in all seven US/UK poverty DataFrame helpers and converts nonfinite US household outputs to JSON null, including household-calculator axes. Generic Aggregate and ChangeAggregate means also return None for empty eligible weighted denominators; sums and counts keep their existing behavior.

The five nullable SPM status aliases support native-entity summaries and projection to people. Poverty, Aggregate, and ChangeAggregate now reject upward or group-to-group status mapping, including filter-variable paths, before generic mapping can turn missing status into measured zero. Generic amount mapping remains unchanged. Weighted calculations use MicroSeries operations and the existing entity mapper.

Validation on the current main base: 152 focused tests pass under Python 3.14.4, with identical pinned base/test dependencies to the reviewed Python 3.13.9 and 3.14.4 runs. make format, make lint, and git diff --check pass. The suite covers all five aliases, unequal weights, SPM-unit-to-person projection, empty/outside-only/zero-weight populations, demographic exports, baseline/reform missingness, household scalar/axes strict JSON, and measured-variable/filter mapping guards. Disabling the guards in the test process makes all 30 rejection regressions fail.

The focused command is POLICYENGINE_SKIP_COUNTRY_IMPORTS=1 uv run --no-sync pytest --noconftest tests/test_poverty_run.py tests/test_nullable_poverty.py -q. The unchanged root conftest.py eagerly imports country fixtures, so --noconftest permits these synthetic wrapper checks in a base-only environment. This verification does not establish full managed country/model/dataset compatibility.

This is a source-only companion to country PR #9462, calculator PR #45, and the wider wrapper work in #515. Country/calculator source retains responsibility for the measurement source and year, membership construction, eligibility, and outside-universe resource/threshold valuation. This PR consumes the resulting nullable statuses; it does not infer those contracts, change finite amount outputs, update dependency pins, certify data, or qualify a managed population runtime. Direct use of the generic mapper and other variables retains existing missing-value aggregation semantics.

Please keep this PR draft. Publication does not authorize merge, release, data replacement, or deployment.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve nullable SPM statuses in wrapper summaries and JSON

1 participant