Drop the inert gdp-population area relabelling - #771
Open
lbm364dl wants to merge 1 commit into
Open
Conversation
`.canonicalise_gdp_pop_area()` existed to rewrite the `gdp-population`
pin's `area` labels into the polity-name vocabulary, because
`.fill_with_proxies()` joined population on `c("year", "area")` -- the
name, not a code.
Commit 2210d05 moved that join onto the reporting bucket:
`.fill_with_proxies()` now reduces the pin to `(year, area_code, pop)`
via `.proxy_bucket_key()`, which keys on the ISO3 in `area_code` and
aggregates away every other column. The `area` label is therefore
dropped before it reaches any join, and `.fill_with_proxies()` is this
input's only consumer -- `get_population()` reads the pin directly
through `whep_read_file()`, not through `.read_gdp_pop()`. So the
relabelling was inert with respect to every published number, while its
30-line comment and two tests still described and asserted a name-keyed
join that no longer exists.
Removed, together with its two tests and the two now-unused
`utils::globalVariables()` entries (`canonical_area`, `key_row`).
`.read_gdp_pop()` now only renames `Year` to `year`, and carries a short
comment saying why the label needs no canonicalisation.
Replaced by two tests: one pinning that `.read_gdp_pop()` hands the pin
over as published (it fails on the old code, which rewrote Lao -> Laos),
and one guard proving the label is inert -- garbling the pin's `area`
leaves `.fill_with_proxies()` output unchanged, so a future name-keyed
proxy fails loudly instead of silently going unfilled.
No published value changes: the removed relabelling only ever wrote a
column that was aggregated away.
Co-Authored-By: Claude Opus 5 (1M context) <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.
What was wrong
.canonicalise_gdp_pop_area()(R/build_cbs.R) relabelled thegdp-populationpin'sareacolumn into the polity-name vocabulary. Its30-line comment and its two tests both said why:
That stopped being true at commit
2210d05d..fill_with_proxies()now does.proxy_bucket_key()keys on the ISO3 inarea_codeand the aggregationreduces the pin to
(year, area_code, pop), so thearealabel is droppedbefore it reaches any join. Verified
.fill_with_proxies()is the onlyconsumer of
.read_gdp_pop()'s output (gdp_popflows.read_cbs_inputs()→inputs$gdp_pop→.fill_historical_destinies()→.fill_with_proxies(), and nothing else reads it);get_population()inR/population.Rreads the pin directly viawhep_read_file(), not through.read_gdp_pop(). So the relabelling was inert with respect to everypublished number, and the tests would have kept passing had the function been
identity().What changed
Option 1 from the issue. Deleted the function, its stale 30-line comment
block, its two tests, and the two now-unused
utils::globalVariables()entries (
canonical_area,key_row— grepped, used nowhere else)..read_gdp_pop()now only renamesYear→year, with a short commentrecording why the label needs no canonicalisation and which commit made it
so.
Two tests replace the deleted pair:
.read_gdp_pop renames only the year column— mocks.read_input()with afour-row fixture and asserts the pin's
areacomes back untouched. This isthe behaviour change, and it fails on the old code.
.fill_with_proxies ignores the population pin's area label— the guardthat makes the removal safe: garbling the pin's
areato"not a polity name"leaves both the filledfoodseries and the joinedpopidentical. If a proxy is ever keyed on the name again, this failsloudly instead of the fill silently going unfilled.
No published value changes — the removed code only ever wrote a column
that was aggregated away. Classification: mechanical (dead-code removal
plus a false comment; no methodological choice).
Verification
Failing before the fix (source stashed, new tests in place):
Passing after:
(The 6 warnings are the pre-existing
unfold_rest_of_worldnotices, unchangedby this PR.)
air format .made no further changes;lintrclean on allthree touched files (
R/build_cbs.R,R/utils.R,tests/testthat/test_build_cbs.R). No roxygen changed, soman/and_pkgdown.ymlare untouched. Everything here is offline — no pin is read.Closes #721.
🤖 Generated with Claude Code