Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
AggregateandChangeAggregatemeans also returnNonefor 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, andChangeAggregatenow 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 useMicroSeriesoperations and the existing entity mapper.Validation on the current
mainbase: 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, andgit diff --checkpass. 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 rootconftest.pyeagerly imports country fixtures, so--noconftestpermits 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.