From 9339129c40de9bde458317105f0c2353228f3b6c Mon Sep 17 00:00:00 2001 From: Vahid Ahmadi Date: Fri, 11 Jul 2025 14:26:43 +0100 Subject: [PATCH 01/13] Parameterize age 35 --- changelog_entry.yaml | 4 ++++ .../dwp/LHA/shared_accommodation_age_threshold.yaml | 12 ++++++++++++ policyengine_uk/variables/gov/dwp/LHA_category.py | 7 +++++-- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 policyengine_uk/parameters/gov/dwp/LHA/shared_accommodation_age_threshold.yaml diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..2de94b35e 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: patch + changes: + fixed: + - Parameterize age 35 threshold in LHA shared accommodation rules \ No newline at end of file diff --git a/policyengine_uk/parameters/gov/dwp/LHA/shared_accommodation_age_threshold.yaml b/policyengine_uk/parameters/gov/dwp/LHA/shared_accommodation_age_threshold.yaml new file mode 100644 index 000000000..cc70d5d95 --- /dev/null +++ b/policyengine_uk/parameters/gov/dwp/LHA/shared_accommodation_age_threshold.yaml @@ -0,0 +1,12 @@ +description: Age threshold below which single adults without children can only claim shared accommodation rates under LHA +values: + 2013-04-01: 35 +metadata: + period: year + unit: year + label: LHA shared accommodation age threshold + reference: + - title: The Housing Benefit Regulations 2006 - Schedule 4 - Paragraph 28 + href: https://www.legislation.gov.uk/uksi/2013/376/schedule/4/paragraph/28 + - title: LHA shared accommodation rate guidance + href: https://www.gov.uk/government/publications/local-housing-allowance-rates-applicable-from-april-2013 \ No newline at end of file diff --git a/policyengine_uk/variables/gov/dwp/LHA_category.py b/policyengine_uk/variables/gov/dwp/LHA_category.py index 473fb33ff..9882ef550 100644 --- a/policyengine_uk/variables/gov/dwp/LHA_category.py +++ b/policyengine_uk/variables/gov/dwp/LHA_category.py @@ -36,11 +36,14 @@ def formula(benunit, period, parameters): household.max(person("age", period)) ) has_children = benunit.any(person("is_child", period)) - # Households with only one adult, if under 35, can only claim shared if without children: + # Households with only one adult, if under age threshold, can only claim shared if without children: # https://www.legislation.gov.uk/uksi/2013/376/schedule/4/paragraph/28 + age_threshold = parameters( + period + ).gov.dwp.LHA.shared_accommodation_age_threshold can_only_claim_shared = ( (num_adults_in_hh == 1) - & (eldest_adult_age_in_hh < 35) + & (eldest_adult_age_in_hh < age_threshold) & ~has_children ) return select( From 3ebbc89977a10d45f922ff013cfd495a2a42aca4 Mon Sep 17 00:00:00 2001 From: Vahid Ahmadi Date: Fri, 18 Jul 2025 11:56:36 +0100 Subject: [PATCH 02/13] edit --- policyengine_uk/variables/gov/dwp/LHA_category.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/policyengine_uk/variables/gov/dwp/LHA_category.py b/policyengine_uk/variables/gov/dwp/LHA_category.py index 9882ef550..077e7770b 100644 --- a/policyengine_uk/variables/gov/dwp/LHA_category.py +++ b/policyengine_uk/variables/gov/dwp/LHA_category.py @@ -38,9 +38,8 @@ def formula(benunit, period, parameters): has_children = benunit.any(person("is_child", period)) # Households with only one adult, if under age threshold, can only claim shared if without children: # https://www.legislation.gov.uk/uksi/2013/376/schedule/4/paragraph/28 - age_threshold = parameters( - period - ).gov.dwp.LHA.shared_accommodation_age_threshold + p = parameters(period) + age_threshold = p.gov.dwp.LHA.shared_accommodation_age_threshold can_only_claim_shared = ( (num_adults_in_hh == 1) & (eldest_adult_age_in_hh < age_threshold) From a5df8765b9d7ee3d6d9a8f941f906f81ccf44e8c Mon Sep 17 00:00:00 2001 From: Vahid Ahmadi Date: Mon, 21 Jul 2025 09:59:55 +0100 Subject: [PATCH 03/13] apply max comments --- policyengine_uk/variables/gov/dwp/LHA_category.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/policyengine_uk/variables/gov/dwp/LHA_category.py b/policyengine_uk/variables/gov/dwp/LHA_category.py index 077e7770b..4369497d3 100644 --- a/policyengine_uk/variables/gov/dwp/LHA_category.py +++ b/policyengine_uk/variables/gov/dwp/LHA_category.py @@ -36,13 +36,13 @@ def formula(benunit, period, parameters): household.max(person("age", period)) ) has_children = benunit.any(person("is_child", period)) - # Households with only one adult, if under age threshold, can only claim shared if without children: + # Households with only one adult, if under age threshold, can only + # claim shared if without children: # https://www.legislation.gov.uk/uksi/2013/376/schedule/4/paragraph/28 - p = parameters(period) - age_threshold = p.gov.dwp.LHA.shared_accommodation_age_threshold + p = parameters(period).gov.dwp.LHA can_only_claim_shared = ( (num_adults_in_hh == 1) - & (eldest_adult_age_in_hh < age_threshold) + & (eldest_adult_age_in_hh < p.shared_accommodation_age_threshold) & ~has_children ) return select( From b582103b939443778499c52c1003d60815356f34 Mon Sep 17 00:00:00 2001 From: Vahid Ahmadi Date: Mon, 21 Jul 2025 10:07:50 +0100 Subject: [PATCH 04/13] debug --- policyengine_uk/variables/gov/dwp/BRMA_LHA_rate.py | 4 ++-- policyengine_uk/variables/gov/dwp/LHA_category.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/policyengine_uk/variables/gov/dwp/BRMA_LHA_rate.py b/policyengine_uk/variables/gov/dwp/BRMA_LHA_rate.py index a9e43282e..4ad3e1036 100644 --- a/policyengine_uk/variables/gov/dwp/BRMA_LHA_rate.py +++ b/policyengine_uk/variables/gov/dwp/BRMA_LHA_rate.py @@ -24,10 +24,10 @@ def formula(benunit, period, parameters): ) category = benunit("LHA_category", period).decode_to_str() - from policyengine_uk.parameters.gov.dwp.LHA import lha_list_of_rents + from policyengine_uk.parameters.gov.dwp.lha import lha_list_of_rents parameters = benunit.simulation.tax_benefit_system.parameters - lha = parameters.gov.dwp.LHA + lha = parameters.gov.dwp.lha # We first need to know what time period to collect rents from. If LHA is frozen, we need to look earlier # than the current time period. diff --git a/policyengine_uk/variables/gov/dwp/LHA_category.py b/policyengine_uk/variables/gov/dwp/LHA_category.py index 4369497d3..11fc47342 100644 --- a/policyengine_uk/variables/gov/dwp/LHA_category.py +++ b/policyengine_uk/variables/gov/dwp/LHA_category.py @@ -39,7 +39,7 @@ def formula(benunit, period, parameters): # Households with only one adult, if under age threshold, can only # claim shared if without children: # https://www.legislation.gov.uk/uksi/2013/376/schedule/4/paragraph/28 - p = parameters(period).gov.dwp.LHA + p = parameters(period).gov.dwp.lha can_only_claim_shared = ( (num_adults_in_hh == 1) & (eldest_adult_age_in_hh < p.shared_accommodation_age_threshold) From 1401af30231d6dfc50d1255c6524506bdbed3d46 Mon Sep 17 00:00:00 2001 From: Vahid Ahmadi Date: Mon, 21 Jul 2025 10:35:48 +0100 Subject: [PATCH 05/13] Fix Makefile to use current Python environment for tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use 'python -m policyengine_core.scripts.policyengine_command' instead of 'policyengine-core' to ensure tests run in the current Python environment and avoid module import errors. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c2cbb51af..019064092 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ format: black . -l 79 test: - policyengine-core test policyengine_uk/tests/policy -c policyengine_uk + python -m policyengine_core.scripts.policyengine_command test policyengine_uk/tests/policy -c policyengine_uk pytest policyengine_uk/tests/ -v python policyengine_uk/data/economic_assumptions.py From 498cdca673937f6eb426c49bf2cfb55087968815 Mon Sep 17 00:00:00 2001 From: Vahid Ahmadi Date: Mon, 21 Jul 2025 10:55:28 +0100 Subject: [PATCH 06/13] matplotlib --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index e41ba3529..dcdb614fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,7 @@ requires-python = ">=3.10" dependencies = [ "policyengine-core>=3.6.4", "microdf-python", + "matplotlib", ] [project.urls] From 593254e0b4612f014f33553d9cd79b9d3e08667c Mon Sep 17 00:00:00 2001 From: Vahid Ahmadi Date: Mon, 21 Jul 2025 11:01:03 +0100 Subject: [PATCH 07/13] undo some changes --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d1a7aa499..33ddf37ab 100644 --- a/Makefile +++ b/Makefile @@ -12,8 +12,8 @@ format: black . -l 79 test: - python -m policyengine_core.scripts.policyengine_command test policyengine_uk/tests/policy -c policyengine_uk - pytest policyengine_uk/tests/ -v + policyengine-core test policyengine_uk/tests/policy -c policyengine_uk + pytest policyengine_uk/tests/ --cov=policyengine_uk --cov-report=xml --maxfail=0 -v update-tests: python policyengine_uk/data/economic_assumptions.py From 9e83e1cc1313994867eefd671ec224d1b0066c9e Mon Sep 17 00:00:00 2001 From: Vahid Ahmadi Date: Mon, 21 Jul 2025 11:06:35 +0100 Subject: [PATCH 08/13] taxcalc --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index dcdb614fc..f9d784f01 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ dependencies = [ "policyengine-core>=3.6.4", "microdf-python", "matplotlib", + "taxcalc", ] [project.urls] From 6dbe7af8c5e302b3d01d497fa0498f6f2060d16c Mon Sep 17 00:00:00 2001 From: Vahid Ahmadi Date: Mon, 21 Jul 2025 11:26:06 +0100 Subject: [PATCH 09/13] taxcalc --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index dcdb614fc..f9d784f01 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ dependencies = [ "policyengine-core>=3.6.4", "microdf-python", "matplotlib", + "taxcalc", ] [project.urls] From 2f293bab63fa1dbd936fccefe9ada2c3f3612645 Mon Sep 17 00:00:00 2001 From: Vahid Ahmadi Date: Thu, 24 Jul 2025 11:13:39 +0100 Subject: [PATCH 10/13] debug --- policyengine_uk/variables/gov/dwp/BRMA_LHA_rate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/policyengine_uk/variables/gov/dwp/BRMA_LHA_rate.py b/policyengine_uk/variables/gov/dwp/BRMA_LHA_rate.py index a9e43282e..4ad3e1036 100644 --- a/policyengine_uk/variables/gov/dwp/BRMA_LHA_rate.py +++ b/policyengine_uk/variables/gov/dwp/BRMA_LHA_rate.py @@ -24,10 +24,10 @@ def formula(benunit, period, parameters): ) category = benunit("LHA_category", period).decode_to_str() - from policyengine_uk.parameters.gov.dwp.LHA import lha_list_of_rents + from policyengine_uk.parameters.gov.dwp.lha import lha_list_of_rents parameters = benunit.simulation.tax_benefit_system.parameters - lha = parameters.gov.dwp.LHA + lha = parameters.gov.dwp.lha # We first need to know what time period to collect rents from. If LHA is frozen, we need to look earlier # than the current time period. From a0109a83de8c78f4496d5ef3717c9a84689289bf Mon Sep 17 00:00:00 2001 From: Vahid Ahmadi Date: Thu, 24 Jul 2025 11:36:00 +0100 Subject: [PATCH 11/13] Merge branch 'master' into parameterize-lha-age-35 --- CHANGELOG.md | 7 +++++++ changelog.yaml | 5 +++++ changelog_entry.yaml | 2 +- pyproject.toml | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a60043e6..76ae6556c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.41.2] - 2025-07-24 10:30:43 + +### Fixed + +- debug LHA lowercase + ## [2.41.1] - 2025-07-22 20:55:35 ### Changed @@ -1998,6 +2004,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 +[2.41.2]: https://github.com/PolicyEngine/openfisca-uk/compare/2.41.1...2.41.2 [2.41.1]: https://github.com/PolicyEngine/openfisca-uk/compare/2.41.0...2.41.1 [2.41.0]: https://github.com/PolicyEngine/openfisca-uk/compare/2.40.2...2.41.0 [2.40.2]: https://github.com/PolicyEngine/openfisca-uk/compare/2.40.1...2.40.2 diff --git a/changelog.yaml b/changelog.yaml index ecb9dbd3e..1c0cd2168 100644 --- a/changelog.yaml +++ b/changelog.yaml @@ -1688,3 +1688,8 @@ changed: - Update microdf_python dependency to >=1.0.0. date: 2025-07-22 20:55:35 +- bump: patch + changes: + fixed: + - debug LHA lowercase + date: 2025-07-24 10:30:43 diff --git a/changelog_entry.yaml b/changelog_entry.yaml index 8ec708bef..2de94b35e 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -1,4 +1,4 @@ - bump: patch changes: fixed: - - Parameterize age 35 threshold in LHA shared accommodation rules + - Parameterize age 35 threshold in LHA shared accommodation rules \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 3ffac1c31..3ad25e5fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "policyengine-uk" -version = "2.41.1" +version = "2.41.2" description = "PolicyEngine tax and benefit system for the UK" readme = "README.md" authors = [ From 4ce126748865a6fe390f4881eb54454e2657e046 Mon Sep 17 00:00:00 2001 From: Vahid Ahmadi Date: Thu, 24 Jul 2025 12:27:15 +0100 Subject: [PATCH 12/13] Merge branch 'master' into parameterize-lha-age-35 --- CHANGELOG.md | 7 +++++++ changelog.yaml | 5 +++++ pyproject.toml | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a60043e6..76ae6556c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.41.2] - 2025-07-24 10:30:43 + +### Fixed + +- debug LHA lowercase + ## [2.41.1] - 2025-07-22 20:55:35 ### Changed @@ -1998,6 +2004,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 +[2.41.2]: https://github.com/PolicyEngine/openfisca-uk/compare/2.41.1...2.41.2 [2.41.1]: https://github.com/PolicyEngine/openfisca-uk/compare/2.41.0...2.41.1 [2.41.0]: https://github.com/PolicyEngine/openfisca-uk/compare/2.40.2...2.41.0 [2.40.2]: https://github.com/PolicyEngine/openfisca-uk/compare/2.40.1...2.40.2 diff --git a/changelog.yaml b/changelog.yaml index ecb9dbd3e..1c0cd2168 100644 --- a/changelog.yaml +++ b/changelog.yaml @@ -1688,3 +1688,8 @@ changed: - Update microdf_python dependency to >=1.0.0. date: 2025-07-22 20:55:35 +- bump: patch + changes: + fixed: + - debug LHA lowercase + date: 2025-07-24 10:30:43 diff --git a/pyproject.toml b/pyproject.toml index 3ffac1c31..3ad25e5fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "policyengine-uk" -version = "2.41.1" +version = "2.41.2" description = "PolicyEngine tax and benefit system for the UK" readme = "README.md" authors = [ From 008e7f6c5bb0fb24fe0cc991843d8f8e20a99eb5 Mon Sep 17 00:00:00 2001 From: Vahid Ahmadi Date: Thu, 24 Jul 2025 14:57:59 +0100 Subject: [PATCH 13/13] debug --- policyengine_uk/variables/gov/dwp/LHA_category.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/policyengine_uk/variables/gov/dwp/LHA_category.py b/policyengine_uk/variables/gov/dwp/LHA_category.py index 11fc47342..4369497d3 100644 --- a/policyengine_uk/variables/gov/dwp/LHA_category.py +++ b/policyengine_uk/variables/gov/dwp/LHA_category.py @@ -39,7 +39,7 @@ def formula(benunit, period, parameters): # Households with only one adult, if under age threshold, can only # claim shared if without children: # https://www.legislation.gov.uk/uksi/2013/376/schedule/4/paragraph/28 - p = parameters(period).gov.dwp.lha + p = parameters(period).gov.dwp.LHA can_only_claim_shared = ( (num_adults_in_hh == 1) & (eldest_adult_age_in_hh < p.shared_accommodation_age_threshold) diff --git a/pyproject.toml b/pyproject.toml index 3ad25e5fb..ae7986d29 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ classifiers = [ requires-python = ">=3.10" dependencies = [ "policyengine-core>=3.6.4", - "microdf-python", + "microdf-python==0.4.4", ] [project.urls]