-
Notifications
You must be signed in to change notification settings - Fork 31
Remove randomness from country package #1439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
4 tasks
Move stochastic variable generation to data package. Variables now read pre-computed values from datasets for deterministic, reproducible calculations. Changes: - would_claim_pc, would_claim_uc, would_claim_child_benefit, child_benefit_opts_out, would_evade_tv_licence_fee, household_owns_tv, main_residential_property_purchased_is_first_home, is_disabled_for_benefits: Remove formulas, use default_value - would_claim_marriage_allowance: New variable for take-up decision - marriage_allowance: Use would_claim_marriage_allowance instead of random() - attends_private_school: Use pre-generated random draw from dataset - is_higher_earner: Use age as deterministic tie-breaker instead of random() 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Tests verify: - Default values work correctly in policy calculator mode - Variables can be explicitly overridden in situations - is_higher_earner uses deterministic tie-breaking (older wins) - Calculations are deterministic across multiple runs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add SCP variable and parameters with would_claim_scp for deterministic take-up (matching the pattern for other benefits in this PR). Changes: - Add would_claim_scp variable (default True, generated in dataset) - Add scottish_child_payment variable with defined_for="would_claim_scp" - Add is_scp_eligible_child helper variable - Add SCP parameters with legislation references: - amount.yaml (Regulation 20) - max_age.yaml (Regulation 18) - premium_under_one_amount.yaml (Scottish Budget 2026-27) - qualifying_benefits/ (Regulation 14) - takeup_rate/ (for dataset generation) - Add tests for SCP baby bonus Source: The Scottish Child Payment Regulations 2020 https://www.legislation.gov.uk/ssi/2020/351/contents Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
9f18b84 to
c84ae00
Compare
- Create scottish_child_payment_person at Person level with defined_for - Keep scottish_child_payment at BenUnit level using adds to aggregate - Maintains backward compatibility with existing tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Collaborator
Author
Microsimulation ValidationThe new dataset (policyengine-uk-data 1.34.0) with Takeup Rates
SCP Amounts (2025)
Full Validation Notebook |
- Add 2026-04-01: £28.20 rate (inflation increase per Scottish Budget) - Change baby boost start from 2026-04-06 to 2027-04-06 (payments start 2027-28) Source: Scottish Budget 2026-27 confirms "will be paid in 2027-28" https://www.gov.scot/publications/scottish-budget-2026-2027/pages/6/ Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove unconfirmed 2026 rate (£28.20) - belongs in PR #1475 - Update baby bonus tests to use £27.15 standard rate - Baby boost starts 2027-04-06 per Scottish Budget announcement Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Baby bonus (SCP Premium for under-ones) belongs in draft PR #1475 (Scottish Budget 2026-27), not this deterministic takeup PR. This PR is only about migrating from random() to would_claim_scp. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove BenUnit wrapper - scottish_child_payment is now Person-level with defined_for="is_scp_eligible". Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tests now specify per-person expected values since scottish_child_payment is a Person-level variable. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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
is_higher_earneruses age as deterministic tie-breaker instead of random noiseChanges
would_claim_pcdefault_value = Truewould_claim_ucdefault_value = Truewould_claim_child_benefitdefault_value = Truechild_benefit_opts_outdefault_value = Falsewould_evade_tv_licence_feedefault_value = Falsehousehold_owns_tvdefault_value = Truemain_residential_property_purchased_is_first_homedefault_value = Falseis_disabled_for_benefitsdefault_value = Falsewould_claim_marriage_allowancemarriage_allowancewould_claim_marriage_allowanceinstead ofrandom()attends_private_schoolis_higher_earnerRelated PRs
Test plan
🤖 Generated with Claude Code