Commit 5fd53eb
Fix DC SNAP state target drop caused by FIPS type coercion (#772)
`_add_snap_metric_columns` in utils/loss.py wrote
`STATE_ABBR_TO_FIPS["DC"] = 11` (int) before looking up state FIPS
strings. The subsequent comparison `state_fips == r.GEO_ID[-2:]`
compares DC's int 11 to the string "11", which is always False, so
DC SNAP state calibration targets were silently dropped.
Worse, `STATE_ABBR_TO_FIPS` is the shared module-level dict from
`storage/calibration_targets/pull_soi_targets.py` — DC is already
defined there as the string "11" — so the write also corrupted the
dict for every downstream consumer (etl_irs_soi.py, pull_soi_targets.py)
after the function ran.
The fix is to delete the line. DC is already present as "11" (str)
in the canonical dict.
Add a regression test that asserts all STATE_ABBR_TO_FIPS entries are
2-character strings and that importing `utils.loss` does not mutate
the dict.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 3268136 commit 5fd53eb
3 files changed
Lines changed: 44 additions & 1 deletion
File tree
- changelog.d
- policyengine_us_data/utils
- tests/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1129 | 1129 | | |
1130 | 1130 | | |
1131 | 1131 | | |
1132 | | - | |
1133 | 1132 | | |
1134 | 1133 | | |
1135 | 1134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
0 commit comments