Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black==25.1.0
pip install black
- name: Check formatting
run: black . -l 79 --check
test:
Expand Down
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: patch
changes:
fixed:
- Use region.values for Scotland comparisons in loss function to ensure consistent behavior with StringArray types
6 changes: 2 additions & 4 deletions policyengine_uk_data/tests/test_scotland_uc_babies.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ def test_scotland_uc_households_child_under_1(baseline):
Target: ~14,000 households (13,992 from Stat-Xplore November 2023)
Source: DWP Stat-Xplore UC Households dataset
"""
region = baseline.calculate(
"region", map_to="household", period=2025
).values
region = baseline.calculate("region", map_to="household", period=2025)
uc = baseline.calculate("universal_credit", period=2025).values
household_weight = baseline.calculate(
"household_weight", map_to="household", period=2025
Expand All @@ -38,7 +36,7 @@ def test_scotland_uc_households_child_under_1(baseline):
)

scotland_uc_child_under_1 = (
(region == "SCOTLAND") & (uc > 0) & has_child_under_1
(region.values == "SCOTLAND") & (uc > 0) & has_child_under_1
)
total = (household_weight * scotland_uc_child_under_1).sum()

Expand Down
4 changes: 2 additions & 2 deletions policyengine_uk_data/utils/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def pe_count(*variables):
# Children under 16 in Scotland
# Source: NRS mid-year population estimates
# https://www.nrscotland.gov.uk/statistics-and-data/statistics/statistics-by-theme/population/population-estimates/mid-year-population-estimates
scotland_children_under_16 = (region == "SCOTLAND") & (age < 16)
scotland_children_under_16 = (region.values == "SCOTLAND") & (age < 16)
df["ons/scotland_children_under_16"] = household_from_person(
scotland_children_under_16
)
Expand All @@ -276,7 +276,7 @@ def pe_count(*variables):
# Source: NRS Vital Events - births registered in Scotland
# https://www.nrscotland.gov.uk/publications/vital-events-reference-tables-2024/
# ~46,000 births per year (45,763 in 2024)
scotland_babies_under_1 = (region == "SCOTLAND") & (age < 1)
scotland_babies_under_1 = (region.values == "SCOTLAND") & (age < 1)
df["ons/scotland_babies_under_1"] = household_from_person(
scotland_babies_under_1
)
Expand Down