Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2f5880d
add codecov coverage
juaristi22 Jul 15, 2025
8ef324b
Merge branch 'master' of https://github.com/PolicyEngine/policyengine…
juaristi22 Jul 15, 2025
069e93a
rename all variables and functions with lowercase
juaristi22 Jul 15, 2025
b5b2912
changelog_entry
juaristi22 Jul 15, 2025
53a0976
bring back BenUnit
juaristi22 Jul 15, 2025
65f4410
renaming files to follow snake case
juaristi22 Jul 15, 2025
eb6fc29
make p widely used in variale formulas
juaristi22 Jul 16, 2025
7c6ca9f
Merge branch 'master' of https://github.com/PolicyEngine/policyengine…
juaristi22 Jul 16, 2025
7b9d17f
lowercase lha test
juaristi22 Jul 16, 2025
fddfc4f
cleaned cached files to avoid import errors
juaristi22 Jul 16, 2025
6434250
switch off case insenstivity in git so it will record file name changes
juaristi22 Jul 16, 2025
1fb6426
removing leftover uppercase directories
juaristi22 Jul 16, 2025
244bd76
manually removing cached directories with uppercase in them
juaristi22 Jul 16, 2025
c2e5a5a
Merge branch 'master' of https://github.com/PolicyEngine/policyengine…
juaristi22 Jul 17, 2025
5eaf0fa
Merge origin/master into maria/minor_repo_fixes
PolicyEngine-Bot Dec 8, 2025
69201bc
Fix lowercase parameter reference and add backwards-compatible variab…
PolicyEngine-Bot Dec 8, 2025
315ac2a
Add backwards compatibility for parameter name lookups
PolicyEngine-Bot Dec 8, 2025
fba0325
Fix remaining mixed-case variable references in test YAML files
PolicyEngine-Bot Dec 9, 2025
da01ea5
Fix circular reference in rent variable formula
PolicyEngine-Bot Dec 9, 2025
68dc0eb
Fix circular reference in rent formula by checking known_periods
PolicyEngine-Bot Dec 9, 2025
5b57b1b
Fix rent circular reference by using holder.get_array() instead of re…
PolicyEngine-Bot Dec 9, 2025
da6c3b2
Fix TypeError in rent.py by converting data_year to int
PolicyEngine-Bot Dec 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- bump: minor
changes:
added:
- Renaming variables to lowercase.
- Extending the use of "p" for "parameter" in variable formulas.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ values:
2024-01-01: 80_000
metadata:
period: year
name: CB_HITC_reduction_threshold
name: cb_hitc_reduction_threshold
label: Child Benefit Tax Charge phase-out end
unit: currency-GBP
reference:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ values:
2024-01-01: 60_000
metadata:
period: year
name: CB_HITC_reduction_threshold
name: cb_hitc_reduction_threshold
label: Child Benefit Tax Charge phase-out threshold
unit: currency-GBP
reference:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ values:
- savings_income_tax
- dividend_income_tax
- property_income_tax
- CB_HITC
- cb_hitc
- personal_pension_contributions_tax
6 changes: 3 additions & 3 deletions policyengine_uk/reforms/conservatives/household_based_hitc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from policyengine_uk.model_api import *


class CB_HITC(Variable):
class cb_hitc(Variable):
value_type = float
entity = Person
label = "Child Benefit High-Income Tax Charge"
Expand All @@ -12,7 +12,7 @@ class CB_HITC(Variable):

def formula(person, period, parameters):
CB_received = person.benunit("child_benefit", period)
hitc = parameters(period).gov.hmrc.income_tax.charges.CB_HITC
hitc = parameters(period).gov.hmrc.income_tax.charges.cb_hitc
personal_income = person("adjusted_net_income", period)
income = person.benunit.sum(personal_income)
percentage = max_(income - hitc.phase_out_start, 0) / (
Expand All @@ -23,7 +23,7 @@ def formula(person, period, parameters):

class make_cb_hitc_household_based(Variable):
def apply(self):
self.update_variable(CB_HITC)
self.update_variable(cb_hitc)


def create_household_based_hitc_reform(parameters, period):
Expand Down
4 changes: 2 additions & 2 deletions policyengine_uk/scenarios/uc_reform.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ def add_universal_credit_reform(sim: Microsimulation):
if not rebalancing.active(year):
continue
is_post_25_claimant = uc_seed < p_uc_post_2026_status[year]
current_health_element = sim.calculate("uc_LCWRA_element", year)
current_health_element = sim.calculate("uc_lcwra_element", year)
# Set new claimants to £217.26/month from April 2026 (pre-2026 claimaints keep inflation-linked increases)
# https://bills.parliament.uk/publications/62123/documents/6889#page=16
current_health_element[
(current_health_element > 0) & is_post_25_claimant
] = (
new_claimant_health_element(year) * 12
) # Monthly amount * 12
sim.set_input("uc_LCWRA_element", year, current_health_element)
sim.set_input("uc_lcwra_element", year, current_health_element)

# https://bills.parliament.uk/publications/62123/documents/6889#page=14

Expand Down
8 changes: 7 additions & 1 deletion policyengine_uk/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ def apply_parameter_changes(self, changes: dict):
self.tax_benefit_system.reset_parameters()

for parameter in changes:
# Convert parameter name to lowercase for backwards compatibility
parameter_lowercase = parameter.lower()
p: Parameter = self.tax_benefit_system.parameters.get_child(
parameter
parameter_lowercase
)
if isinstance(changes[parameter], dict):
# Time-period specific changes
Expand Down Expand Up @@ -479,6 +481,10 @@ def calculate(
):
if variable_name is None:
return self.calculate_all()

# Convert variable name to lowercase for backwards compatibility
variable_name = variable_name.lower()

tracer: SimpleTracer = self.tracer
if len(tracer.stack) == 0:
# Only decode enums to string values when we're not within
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
period: 2025
input:
benunit_rent: 8_000
LHA_eligible: false
lha_eligible: false
housing_benefit_applicable_amount: 1_000
housing_benefit_applicable_income: 11_000
LHA_cap: 1_000
lha_cap: 1_000
housing_benefit_non_dep_deductions: 0
output:
housing_benefit_entitlement: 1_500
Expand All @@ -14,10 +14,10 @@
period: 2025
input:
benunit_rent: 8_000
LHA_eligible: true
lha_eligible: true
housing_benefit_applicable_amount: 1_000
housing_benefit_applicable_income: 11_000
LHA_cap: 1_000
lha_cap: 1_000
housing_benefit_non_dep_deductions: 0
output:
housing_benefit_entitlement: 1_000
Expand All @@ -26,10 +26,10 @@
period: 2025
input:
benunit_rent: 8_000
LHA_eligible: false
lha_eligible: false
housing_benefit_applicable_amount: 1_000
housing_benefit_applicable_income: 11_000
LHA_cap: 1_000
lha_cap: 1_000
housing_benefit_non_dep_deductions: 2_000
output:
housing_benefit_entitlement: 0
Expand All @@ -38,10 +38,10 @@
period: 2025
input:
benunit_rent: 6_000
LHA_eligible: false
lha_eligible: false
housing_benefit_applicable_amount: 1_000
housing_benefit_applicable_income: 11_000
LHA_cap: 1_000
lha_cap: 1_000
housing_benefit_non_dep_deductions: 0
output:
housing_benefit_entitlement: 0
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
input:
people:
person1:
is_SP_age: false
is_sp_age: false
person2:
is_SP_age: false
is_sp_age: false
person3:
is_SP_age: false
is_sp_age: false
person4:
is_SP_age: false
is_sp_age: false
benunits:
benunit:
members: [person1, person2, person3, person4]
Expand All @@ -29,13 +29,13 @@
input:
people:
person1:
is_SP_age: false
is_sp_age: false
person2:
is_SP_age: false
is_sp_age: false
person3:
is_SP_age: false
is_sp_age: false
person4:
is_SP_age: false
is_sp_age: false
benunits:
benunit:
members: [person1, person2, person3, person4]
Expand All @@ -54,13 +54,13 @@
input:
people:
person1:
is_SP_age: false
is_sp_age: false
person2:
is_SP_age: false
is_sp_age: false
person3:
is_SP_age: false
is_sp_age: false
person4:
is_SP_age: false
is_sp_age: false
benunits:
benunit:
members: [person1, person2, person3, person4]
Expand All @@ -79,13 +79,13 @@
input:
people:
person1:
is_SP_age: false
is_sp_age: false
person2:
is_SP_age: false
is_sp_age: false
person3:
is_SP_age: false
is_sp_age: false
person4:
is_SP_age: false
is_sp_age: false
benunits:
benunit:
members: [person1, person2, person3, person4]
Expand All @@ -104,13 +104,13 @@
input:
people:
person1:
is_SP_age: false
is_sp_age: false
person2:
is_SP_age: false
is_sp_age: false
person3:
is_SP_age: false
is_sp_age: false
person4:
is_SP_age: false
is_sp_age: false
benunits:
benunit:
members: [person1, person2, person3, person4]
Expand All @@ -129,13 +129,13 @@
input:
people:
person1:
is_SP_age: false
is_sp_age: false
person2:
is_SP_age: false
is_sp_age: false
person3:
is_SP_age: false
is_sp_age: false
person4:
is_SP_age: false
is_sp_age: false
benunits:
benunit:
members: [person1, person2, person3, person4]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
input:
in_social_housing: true
housing_benefit_reported: 1
LHA_eligible: false
lha_eligible: false
output:
housing_benefit_eligible: true

Expand All @@ -14,7 +14,7 @@
input:
in_social_housing: false
housing_benefit_reported: 1
LHA_eligible: true
lha_eligible: true
output:
housing_benefit_eligible: true

Expand All @@ -24,7 +24,7 @@
input:
in_social_housing: false
housing_benefit_reported: 0
LHA_eligible: true
lha_eligible: true
output:
housing_benefit_eligible: false

Expand All @@ -34,6 +34,6 @@
input:
in_social_housing: false
housing_benefit_reported: 1
LHA_eligible: false
lha_eligible: false
output:
housing_benefit_eligible: false
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
absolute_error_margin: 20
input:
age: 18
LHA_category: C
lha_category: C
output:
brma: MAIDSTONE
BRMA_LHA_rate: 9_771
brma_lha_rate: 9_771
- name: BRMA inputs
period: 2020
absolute_error_margin: 0
Expand All @@ -19,8 +19,8 @@
absolute_error_margin: 20
input:
brma: GUILDFORD
LHA_category: C
lha_category: C
output:
brma: GUILDFORD
LHA_category: C
BRMA_LHA_rate: 13_164
lha_category: C
brma_lha_rate: 13_164
Loading
Loading