Repository navigation
Use NumPyro's ZeroSumTransform for latent subpopulation infections. - #936
cdc-mitzimorris wants to merge 79 commits into
Conversation
… zero sum transform
|
Thank you for your contribution @cdc-mitzimorris 🚀! Your github-pages is ready for download 👉 here 👈! |
There was a problem hiding this comment.
🟡 Changes recommended
Process reassignment can bypass the zero-sum constraint, already-adapted processes cannot be reused, and overly strict test tolerances can reject valid float32 results.
3 open issues
What changed in this PR
This PR replaces mean-centering in PyRenew’s subpopulation infection models with NumPyro’s ZeroSumTransform, sampling K - 1 coordinate trajectories for K regions while preserving the existing deviation priors.
Changes:
- Supports both temporal parameterizations, validates shared scalar parameters, and skips deviation sampling for a single subpopulation.
- Adds prior, initialization, timing, and forecast tests, including hospital–wastewater and mobility case–death integrations.
- Updates documentation and test dependencies, including guidance to rerun previously saved fits.
| File | Description |
|---|---|
uv.lock |
Records the added test-analysis dependencies. |
test/test_zero_sum_deviations.py |
Tests coordinates, prior equivalence, timing, replay, and parameter validation. |
test/test_subpopulation_infections.py |
Updates rejection tests for unsupported deviation processes. |
test/test_rt_initialization.py |
Adjusts initialization and calendar expectations for coordinate sampling. |
test/integration/test_subpopulation_infections_hw.py |
Adds hospital–wastewater fitting, diagnostics, and forecast tests. |
test/integration/test_mobility_subpopulation_infections_cases_deaths.py |
Adds synthetic mobility fitting, recovery, and forecast tests. |
test/integration/conftest.py |
Adds tutorial-data and hospital–wastewater model fixtures. |
pyrenew/latent/temporal_processes.py |
Implements zero-sum adapters and scalar parameter checks. |
pyrenew/latent/subpopulation_infections.py |
Integrates adapted deviations and updates API docstrings. |
pyrenew/latent/mobility_subpopulation_infections.py |
Documents the supported deviation processes and parameters. |
pyproject.toml |
Declares analysis dependencies and updates dependency-check exceptions. |
docs/tutorials/latent_subpopulation_infections.qmd |
Explains coordinate sampling, prior preservation, and refitting requirements. |
docs/tutorials/latent_mobility_infections.qmd |
Documents the shared representation and saved-fit migration. |
Review effort: Max
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #936 +/- ##
==========================================
+ Coverage 98.95% 98.96% +0.01%
==========================================
Files 59 59
Lines 2395 2427 +32
==========================================
+ Hits 2370 2402 +32
Misses 25 25
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@SamuelBrand1 - can you review? added a suggested review sequence to the issue description. |

Replace mean subtraction with NumPyro’s ZeroSumTransform, sampling K - 1 trajectories for K subpopulations.
Suggested review sequence: