Repository navigation
UK firm data: region and legal status - #1781
Draft
vahid-ahmadi wants to merge 15 commits into
Draft
vahid-ahmadi wants to merge 15 commits into
vahid-ahmadi wants to merge 15 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… against them Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Port sector-conditional employment, two-universe calibration with per-band registration propensity, stratified thinning with base weights and in_frame/vat_scope flags from firm-microsim-paper. Solve with the public solve_constraint_system (fixes #636) and use the paper's input-ratio imputation (fixes #258). Add the UKFirmRules seam keyed by firm_id, the firm universe helpers, and a policyengine-uk-named firm table export. Name policyengine-uk as the firm rules home in docs/firm-support-plan.md. Refs #1705, PolicyEngine/policyengine-uk#2939. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Commit the paper's processed 2024-25 tables with provenance and golden numbers from paper runs at aa1ce07 (full, fast and CI modes, seed 42). The engine-free test runs a thinned build and checks exact targets and propensities plus distributional tolerances; tools/firm_paper_parity.py prints the full comparison table. Refs #1705. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Share the HMRC band names between firm_universe and firm_generation, remove the unused assign_vat_flags and calculate_vat_liability_values, add UKFirmGenerationConfig.with_vintage, prove thinned solves start from base weights, feed a generated population through the policyengine-uk firm table, rename the parity tool to tools/uk_firm_paper_parity.py, and correct the changelog and docs. Refs #1705. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hash the reference JSON in the fixture provenance with the commands that produced it, assert the golden full run reproduces the paper's published 2024-25 headline, reuse the shared HMRC band names, and note the parity test in the firm support plan. Refs #1705. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pts comparison Carved from #1706's state at bd59841 without the region, legal-status and paybill steps, which move to later PRs of the split. The input-status map covers the 71 policyengine-uk inputs at the committed 0d1c25010 snapshot, with only the base columns set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…apart from the rule period The same-seed thinned 2024-25 population (295,271 rows) is identical, checked exactly against the code before this commit on the same main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…what this PR sets Fable review fixes: the support plan and README no longer say the policyengine-uk adapter is unimplemented; the receipts paybill caveat no longer describes an imputation this PR does not contain; note 4 cites the ONS publication; a FirmRuleOutputs without the VAT output raises ValueError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ompanies and non-profits to charities Region and legal status from ONS UK Business 2025 Tables 8, 12 and 13 (Table 15 held out), the export-group registry with the attributes group, value-free target candidates, and the receipt's data year per input group. ONS status 4 now exports as COMPANY and a public body, status 7 as a charity (assumed); LLPs are a caveat only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 27, 2026
This branch has not been deployed
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.
Refs #1705, #1706, #1756.
Draft. Step 3 of the #1706 split: UK firm region and legal status.
Stacked. The base stays
mainso that CI runs (the test workflow runs only on PRs that targetmain). Until the PRs below merge, this diff also shows their commits: #1756 (shared firm layer), #1706 (UK paper-parity port). Review only this PR's commit,182c939d3. Carved file by file fromuk-firm-paper-parity-full(f644ab023), as agreed in this comment. Everything here is opt-in and experimental; none of it should feed a published costing yet.What this PR contains
uk_runtime/firm_attributes.py), drawn after calibration from ONS UK Business 2025: region given SIC division × turnover band (Table 8), legal status given industry group × turnover band (Table 13), weighted by the employment band (Table 12). Table 15 (region × legal status) is held out. Fixtures with workbook provenance;tools/extract_uk_firm_ons_attribute_tables.py --checkre-extracts them.firm_table.UK_FIRM_EXPORT_GROUPS): the export is a base table plus optional input groups; this PR registersattributesonly. The later PRs each add their groups as registry entries.COMPANYandfirm_is_public_body, so policyengine-uk charges it corporation tax and its Employment Allowance exclusion applies;firm_is_charity, labelled assumed (ONS does not split charities out), which gives it charitable rate relief (pe-uk's EA charity exception only matters for public bodies, and no status 7 body is one);OTHERand public bodies.data_yearsnow adds one key per input group read (firm_build.UK_FIRM_INPUT_DATA_YEARS), apart fromrule_period. This PR addsons_attributes("2025 frame (turnover mostly 2023-24)").firm_target_candidates.py), not wired intouk_firms_targets.jsonor the solve.--attributes-diris required by the build, as on the full branch.Effect of the status 4 and 7 mappings
Measured on a full 2024-25 build of the top of the stack (2,946,015 rows, every opt-in input on, pe-uk
0d1c25010), with taxes evaluated on the same table under the old and new mappings:With this PR alone (no profit, paybill or rateable value inputs) those taxes are zero, so the movement only shows once 4a–4c are in.
Checks
assert_frame_equal(check_exact=True)). The table itself differs:--attributes-diris required, so the attribute columns are added.test_uk_receipt_counts,test_uk_runtime_exportsand the sharedtest_firm_*files pass; ruff check and format pass on the changed files;tools/ci_test_plan.py verifypasses. The full engine-free suite was not run locally.🤖 Generated with Claude Code