Encode HUD Fair Market Rents as a CSV-backed lookup (Phase 1)#8318
Open
PavelMakarchuk wants to merge 2 commits into
Open
Encode HUD Fair Market Rents as a CSV-backed lookup (Phase 1)#8318PavelMakarchuk wants to merge 2 commits into
PavelMakarchuk wants to merge 2 commits into
Conversation
Phase 1 of housing-payment-standards work: establish a HUD-FMR data store separate from the existing LA-only pha_payment_standard prototype. CSV pattern mirrors the ACA SLCSP rating-areas approach (parameters/gov/hud/fmr/fair_market_rents.csv loaded by sibling __init__.py). - New variable hud_fair_market_rent looks up monthly FMR by (county_fips, bedrooms, year) and returns annualised dollars. - Seed CSV ships with a placeholder LA County FY2025 row so tests bind to real schema; tools/download_hud_fmr.py populates the full ~3,000-row county file from HUD's API with a free key. - README documents the schema, refresh workflow, and Phase 1B follow-up (SAFMR ZIP-level resolution). pha_payment_standard.py untouched — Phase 2 will refactor it to read from the FMR store with a PHA-actual overlay layered on top. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8318 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 1 -2
Lines 63 17 -46
=========================================
- Hits 63 17 -46
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:
|
Replaces the 5-row LA County placeholder with HUD's full FY2025 county FMR table (4,765 counties × 5 bedroom counts = 23,825 rows), pulled from HUD User's FY25_FMRs.xlsx. Adds tools/convert_hud_fmr_xlsx.py: reads HUD's Excel via the python-calamine engine (works around HUD's malformed metadata timestamps that openpyxl rejects), maps HUD's column names to the PE schema, de-duplicates on (state, county_fips, year, bedrooms), and merges into the existing CSV so future years just append. Existing hud_fair_market_rent tests pass unchanged — LA County FY2025 FMR values in the placeholder happened to match HUD's actual published values exactly ($1,900 / $2,160 / $2,750 / $3,573 / $3,920 monthly for 0/1/2/3/4 bedroom). Co-Authored-By: Claude Opus 4.7 (1M context) <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
Phase 1 of the housing-payment-standards work discussed with Matt Unrath: stand up a HUD Fair Market Rent data store so future Section 8 / LIHTC / housing-aid variables have a faithful, refreshable national source of truth.
Pattern mirrors the existing ACA SLCSP rating-areas approach (
parameters/gov/hhs/medicaid/geography/): a CSV in the parameter tree, loaded once at import via a sibling__init__.py, queried at variable-formula time with a pandas merge.What's in this PR
policyengine_us/parameters/gov/hud/fmr/fair_market_rents.csvpolicyengine_us/parameters/gov/hud/fmr/__init__.pycounty_fipsas zero-padded stringpolicyengine_us/parameters/gov/hud/fmr/README.mdpolicyengine_us/variables/gov/hud/hud_fair_market_rent.pypolicyengine_us/tools/download_hud_fmr.pypolicyengine_us/tests/policy/baseline/gov/hud/hud_fair_market_rent.yamlchangelog.d/hud-fmr-encoding.added.mdWhat's deliberately out of scope
small_area_fair_market_rents.csv) and a sibling lookup; same pattern.source_levelcompanion variable for provenance.pha_payment_standard.pyaway from its current LA-County hardcoded prototype. Deferred to Phase 2 so existing tests stay green and the data-infrastructure piece can land cleanly first.--year YYYY.Seed data note
The CSV currently has 5 placeholder LA County rows (one per bedroom count) so the new variable's tests have something concrete to bind to. These should be replaced before merge by running
tools/download_hud_fmr.pywith a free HUD API key (register at https://www.huduser.gov/hudapi/). I'm leaving the PR in draft until that swap happens.Test plan
policyengine-core test policyengine_us/tests/policy/baseline/gov/hud -c policyengine_us— 70 passed (4 new + 66 existing, no regressions)make formatcleandownload_hud_fmr.py🤖 Generated with Claude Code