Repository navigation
Use Rent Service Scotland's own lists of rents for Scottish percentile ratios - #2037
Merged
Merged
Conversation
The Scottish lists in lha_list_of_rents.csv.gz were copies of English BRMAs' lists (#2036). Replace them with Rent Service Scotland's records released under FOI 202200303624: the list for April Y is the sheet for the year to September Y-1 (sheets 2018 and 2019 for 2019 and 2020). Those sheets reproduce the published 30th percentiles to the penny in 87 and 86 of 90 cells respectively. Scottish BRMAs now take percentile-reform ratios from their own lists; Welsh and Northern Irish BRMAs, still copies, keep the median English ratio, and the English median no longer includes Scotland. The build script pins the workbook by sha256 and leaves every other row unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From review: choose the latest list year per region so a newer sheet for one nation cannot drop the others; define English regions once (NON_ENGLISH_REGIONS) for the code and tests; compute the test's English median the way the code does; pin two Scottish P50 ratios so the test catches a return to copied data (both Scottish tests fail on aef9c24's file); assert the number of BRMA-less rents per sheet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #2036
Stacked on #2022 (
lha-published-rates, head aef9c24). Retarget tomainafter #2022 merges.What changes
lha_list_of_rents.csv.gzhad Scottish lists that were copies of English BRMAs' lists (#2036). This replaces them with Rent Service Scotland's own lists, released by the Scottish Government under FOI 202200303624.year2019 is sheet 2018 andyear2020 is sheet 2019._percentile_ratiosreads the file's latest year, 2020, for England and now for Scotland.How well the FOI lists reproduce the published 30th percentile
I applied
statutory_percentile(Sch 3B para 2(8)) with half-up penny rounding to each FOI sheet, and compared the result with the published 30th percentile for the following April.Over all six years, 522 of 540 cells match to the penny. I have not established why the other 18 cells differ.
Effect
The baseline is unchanged, because a ratio is 1 at the 30th percentile. A percentile reform now scales Scottish rates by Scotland's own rent distributions. At the 50th percentile:
Across all 90 Scottish cells, the ratio ranges from 1.010 to 1.267, with a mean of 1.111.
Invariants and tests
test_scottish_lists_are_rent_service_scotlands_own.test_scottish_percentile_ratios_use_scotlands_own_lists.test_welsh_and_ni_percentile_ratios_use_the_english_median, which replaces the devolved test from aef9c24.scripts/build_scottish_list_of_rents.pyfetches the workbook, checks its pinned sha256 and rebuilds the CSV. Starting from aef9c24's file, it reproduces the committed file exactly (sha256 3a083649…).Review
An independent Opus review (
review/REVIEW_2037_r1.md) approved the PR after reading the code; it could not run anything. I applied its findings and ran its four checks:_sorted_list_of_rentstakes the latest year per region, so a newer sheet for one nation can't drop the others.NON_ENGLISH_REGIONSdefines the English set for the code and tests alike.Commands run
uv run --with openpyxl python scripts/build_scottish_list_of_rents.py --cache ~/.cache/lha, starting from aef9c24's file: the output is identical to the committed file.pytest policyengine_uk/tests/test_lha_published_rates.py: 75 passed.ruff formatandruff checkon the changed files: clean.🤖 Generated with Claude Code