-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Problem
economic_impact_analysis() in both us/analysis.py and uk/analysis.py is broken and untested. The API (policyengine-api-v2-alpha) bypasses it entirely, reimplementing all orchestration in computation_modules.py (818 lines) with workarounds for library bugs.
What's broken today
| Issue | Detail |
|---|---|
| Wrong US program names | payroll_tax → employee_payroll_tax, state_income_tax not a program |
Wrong US entity for ssi |
Uses person, should be spm_unit |
| Too many US programs | 11 programs; API only uses 6 that work |
Missing model_rebuild() |
ProgrammeStatistics (UK) never rebuilt |
calculate_decile_impacts() creates new sims |
Wasteful when caller already has run simulations |
| No intra-decile computation | API computes this; library skips it |
| No budget summary | No class exists; API has workaround for double-weighting |
| No poverty by demographics | API computes age/gender/race breakdowns; library skips them |
StopIteration on missing variables |
Crashes instead of clear error |
Solution
- Add
CountryConfigstrategy class withUS_CONFIG/UK_CONFIG— eliminates country conditionals - Add
compute_budget_summary(),compute_decile_impacts(),compute_program_statistics()as individual functions - Add
PolicyReformAnalysisunified result container - Rewrite
economic_impact_analysis()for both countries to use individual compute functions - Fix
model_rebuild()in both__init__.pyfiles - Fix error handling in
Aggregate/ChangeAggregate(StopIteration→ValueError)
This is Phase 1 of consolidating logic from policyengine-api-v2-alpha back into policyengine.py.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels