Restore three_digit_zip_code formula (fixes ACA PTC regression)#7774
Merged
MaxGhenis merged 2 commits intoPolicyEngine:mainfrom Mar 13, 2026
Merged
Conversation
The formula derives the 3-digit ZIP prefix from zip_code (e.g. 90019 → 900) and is independent of ZIP_CODE_DATASET. Its removal silently broke ACA PTC calculations for all LA County households that provide zip_code but not three_digit_zip_code, causing aca_ptc to return 0 instead of ~$5,055. Adds regression tests for the derivation and an integration test reproducing the Amplifi-reported ACA PTC bug. Fixes the regression introduced in 9d05912. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7774 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 1 -1
Lines 13 10 -3
=========================================
- Hits 13 10 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Use integer division (// 100) instead of float (// 1e2) in three_digit_zip_code - Import Simulation from policyengine_us public API, not policyengine_core internals - Add code deletion safety rule to CLAUDE.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
three_digit_zip_codeformula that was incorrectly removed in Remove dead ZIP_CODE_DATASET infrastructure #7695 as part ofZIP_CODE_DATASETcleanupzip_code(e.g.90019→900) and has no dependency onZIP_CODE_DATASETaca_ptc= $0 instead of ~$5,055)Root cause
PR #7695 removed
ZIP_CODE_DATASETinfrastructure, but thethree_digit_zip_codeformula was pure arithmetic (zip_code // 100) with no dataset dependency. Without it,slcsp_rating_area_la_countycan't look up rating areas →slcsp= 0 →aca_ptc= 0.Reported by Paul Huntsberger (Amplifi) in #partner-amplifi.
Test plan
90019→"900"derivation01234→"012"(leading zero preserved)aca_ptc🤖 Generated with Claude Code