You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add rules-based tax-unit construction engine from policyengine-us-data
Extract the rules-based tax-unit / filing-status construction engine from
policyengine-us-data into microunit (roadmap item 2). The engine is copied
verbatim (no logic changes) and made source-agnostic and self-contained. This
integrates additively with the existing unit-assignment scaffold.
New modules:
- src/microunit/tax_unit_construction.py: core engine. Public entry
construct_tax_units(person, year, mode) with "policyengine" (default) and
"census_documented" modes; HEAD/SPOUSE/DEPENDENT role constants. The only
change vs. the source is the internal import (now microunit.rule_helpers);
zero non-import edits to the logic.
- src/microunit/rule_helpers.py: dependency/filing rule helpers (renamed from
tax_unit_rule_helpers). The optional policyengine_us import shim is dropped;
the qualifying-relative gross income limit now loads from packaged data, so
the engine no longer depends on policyengine-us.
- src/microunit/data/dependent_gross_income_limit.yaml: vendored IRC 151(d)
exemption-amount values (through 2026), loaded via importlib.resources.
Integration:
- __init__.py: additively export construct_tax_units, the role constants,
modes, CPSRelationshipCode, and the rule helpers (existing API unchanged).
- units/tax.py: add construct_tax_partition(), a UnitPartition adapter over
construct_tax_units, fulfilling the prior "port rules-based tax-unit
construction here" TODO. assign_tax_partition still preserves native IDs.
- units/__init__.py: export construct_tax_partition.
- pyproject.toml: add numpy and pyyaml deps; ship the YAML as wheel/sdist data.
- uv.lock: regenerated for the new direct dependencies.
- README.md: document the engine, the two modes, the input contract, and the
ACS-column-mapping boundary.
Tests (60 passing total): test_tax_unit_construction.py ports the full CPS
suite to the microunit namespace; test_tax_partition_adapter.py covers the new
adapter; test_import.py checks the public API and packaged-data resolution.
ACS boundary: acs_to_cps_columns.py (ACS-PUMS-specific RELSHIPP/RELP and
spouse/parent inference) is intentionally NOT included. microunit takes
already-normalized CPS-like person frames; ACS column mapping and the
ACS-specific tests remain in policyengine-us-data.
Extracted from PolicyEngine/policyengine-us-data@f7458313.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments