Skip to content

[v4] Unify ProgramStatistics / ProgrammeStatistics#293

Open
MaxGhenis wants to merge 1 commit intov4-provenancefrom
v4-unify-program-stats
Open

[v4] Unify ProgramStatistics / ProgrammeStatistics#293
MaxGhenis wants to merge 1 commit intov4-provenancefrom
v4-unify-program-stats

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

Stacked on #292. Fifth in the v4 chain. Straight deduplication.

What

Two byte-identical classes — `ProgramStatistics` (US) and `ProgrammeStatistics` (UK) — collapse into one `policyengine.outputs.ProgramStatistics`. The British/American spelling split was accidental divergence, not editorial choice, and it was visible at the public API level.

  • Canonical class at `policyengine/outputs/program_statistics.py`
  • Re-exported from `policyengine.outputs`
  • Still available as `policyengine.tax_benefit_models.us.ProgramStatistics` (re-exported from `us/init.py`)
  • UK side renames: `programme_statistics` → `program_statistics` field on `PolicyReformAnalysis`; `programme_name` → `program_name` on the instance; all local variables / DataFrame columns likewise

Migration

```python

Before

from policyengine.tax_benefit_models.uk import ProgrammeStatistics
stats.programme_name

After

from policyengine.outputs import ProgramStatistics # or from .uk
stats.program_name
```

Test plan

  • 205 tests pass locally
  • `ruff check .` + `ruff format --check .` clean

Remaining in v4

  • `MicrosimulationModelVersion` base extraction (~600 LOC duplication)

🤖 Generated with Claude Code

Two byte-identical classes split only by British/American spelling
(program_name vs programme_name). Collapsed into a single
policyengine.outputs.ProgramStatistics; both country analysis helpers
import it from there now. Saves ~106 LOC of duplication and removes
an API-surface footgun for cross-country code.

Changes:

- Add policyengine/outputs/program_statistics.py with the unified class.
- Re-export from policyengine/outputs/__init__.py.
- Delete tax_benefit_models/us/outputs.py and
  tax_benefit_models/uk/outputs.py.
- us/__init__.py and uk/__init__.py re-export from policyengine.outputs.
- uk/analysis.py: rename programme_name -> program_name,
  programme_statistics -> program_statistics, programmes -> programs,
  programme_df/collection -> program_df/collection. Field on
  PolicyReformAnalysis also changes.

Migration for callers:
- from policyengine.tax_benefit_models.uk import ProgrammeStatistics
  -> from policyengine.outputs import ProgramStatistics
- stats.programme_name -> stats.program_name

205 tests pass locally.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant