Skip to content

SWEET holds no income table; the caller passes each country's income group - #116

Merged
HughRunyan merged 3 commits into
mainfrom
income-comes-from-the-caller
Oct 29, 2026
Merged

HughRunyan merged 3 commits into
mainfrom
income-comes-from-the-caller

Conversation

@HughRunyan

@HughRunyan HughRunyan commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

SWEET no longer keeps its own copy of the World Bank income groups. SWEET_python/country_income.py held What a Waste 2.0's 2018 groups, and the site-type rule fell back to it whenever a caller passed no income. Income now comes only from the caller, so every tool reads it from one place: the World Bank list the ingestion pipeline loads (RMI/waste_data_ingestion_pipeline#309).

What changed

  • country_income.py and site_type_defaults.income_for are deleted. Nothing outside SWEET imported them; I checked Climate TRACE and WasteMAP.
  • landfill_is_default / default_site_type: the high-income branch uses only the income_id the caller passes. A missing income counts as not high income, so only the region and named-country rules apply.
  • New arguments, so WasteMAP can pass its income on each path that guesses a type:
    • City.sdst_prepopulate(..., income_by_iso3=): a country→group mapping, looked up once the clicked point's country is known.
    • City.load_andre_params(..., income_id=): the cities table's disposal-split fallback (Singapore, Brunei and others with no split of their own).
    • City.dst_baseline_blank(..., income_id=), passed on to defaults_2019.disposal_split_for: Custom Location.
  • Climate TRACE's site paths already pass their row's income_id; nothing changes there.

Does this change a modelling decision?

  • Yes. site-type-fill in SWEET_python/MODEL_DECISIONS.md now says the caller supplies income.

Do published numbers change?

Only for a caller that passes no income. That caller loses the high-income branch: untyped sites in Australia, Chile and the high-income Caribbean islands default to open dump, and cities in Brunei and Singapore with no split of their own fall back to all dumpsite. WasteMAP's paired PR passes income on every path, so its numbers move only where the World Bank group itself changed since 2018 (Argentina, Guyana and others; see that PR).

Tests

pytest -m "not integration": 710 passed. tests/test_site_type_defaults.py now checks that SWEET holds no table and that the new arguments exist. tests/test_custom_location_disposal_split.py covers Brunei with and without an income.

Pairs with

Acceptance criteria

  • SWEET holds no income table.
  • Every path that guesses a site type, or falls back to a type-based split, takes income from its caller.
  • Tests pass.

Definition of done

  • Acceptance criteria met
  • Tests pass
  • MODEL_DECISIONS.md and the changelog updated
  • Reviewed and merged

🤖 Generated with Claude Code

…roup

country_income.py was a copy of What a Waste 2.0's 2018 World Bank groups,
a second source beside the one the ingestion pipeline now loads from the
World Bank. It and site_type_defaults.income_for are deleted; the site-type
rule's high-income branch uses only the income the caller passes.

New arguments so WasteMAP can pass its build's income: sdst_prepopulate
income_by_iso3, load_andre_params income_id, dst_baseline_blank income_id
(through disposal_split_for). Climate TRACE already passes its row's income.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HughRunyan HughRunyan added enhancement New feature or request model-output-change Changes model OUTPUT values (expected progress, not breaking); results differ from prior runs labels Oct 29, 2026
Copilot AI lite review requested due to automatic review settings October 29, 2026 21:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The public City.site_only_estimate path still omits the caller-provided income_id, causing incorrect site-type guesses and leaving the active contract violation unresolved.

1 open issue
What changed in this PR

This PR removes SWEET’s embedded World Bank income-group table and makes caller-provided income the sole input for site-type and disposal-split fallbacks.

Changes:

  • Deletes country_income.py and removes the internal income fallback.
  • Adds income parameters to city, custom-location, and site-type inference paths.
  • Updates tests, modelling documentation, and the October changelog.
  • Corrects the remaining public site-type path and contradictory changelog entries before approval.

This pull request requires changes.

File Summary
tests/​test_site_type_defaults.py Verifies removal of the embedded income table and the updated income arguments.
tests/​test_custom_location_disposal_split.py Covers custom-location disposal splits with and without caller-provided income.
SWEET_python/​site_type_defaults.py Uses caller-provided income for high-income rules. Moderate issue (2 votes): City.site_only_estimate still calls default_site_type without income.
SWEET_python/​MODEL_DECISIONS.md Documents caller-supplied income as the site-type modelling decision.
SWEET_python/​defaults_2019.py Propagates caller-provided income into disposal-split fallback logic.
SWEET_python/​country_income.py Deletes SWEET’s duplicated World Bank income-group table.
SWEET_python/​city_params.py Adds income inputs to city loading, custom locations, and SDST prepopulation paths.
changelog/​2026-10.md Documents the API and modelling changes. Nit (1 vote): older entries still reference the deleted income module and outdated disposal-split API.

Review effort: Lite

Comment thread SWEET_python/site_type_defaults.py Resolved
HughRunyan and others added 2 commits October 29, 2026 16:06
The last path that guesses a site type with no income argument. Nothing
calls it, but a caller would have lost the high-income rule silently.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings October 29, 2026 23:06
@HughRunyan
HughRunyan merged commit e9d38ac into main Oct 29, 2026
3 checks passed
@HughRunyan
HughRunyan deleted the income-comes-from-the-caller branch October 29, 2026 23:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The review shows no remaining active issues, with the caller-owned income behavior implemented across affected paths and covered by the added disposal tests.

No open issues 🎉

1 resolved since last review

Review effort: Lite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request model-output-change Changes model OUTPUT values (expected progress, not breaking); results differ from prior runs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants