Repository navigation
City ADST: a stated diversion share is what is diverted (no rejects) - #115
Merged
Merged
Conversation
Composting, recycling and combustion no longer return rejects to the landfills in the city-level advanced DST, so a stated share is what is diverted. The city DST, site tool and Climate TRACE keep City's rates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The mass-flow tests omit combustion diversion, leaving a regression to the old 10% combustion loss untested.
1 open issue
What changed in this PR
This PR makes city-level advanced DST diversion shares equal the mass actually diverted, without changing the legacy City paths or facility reject handling.
Changes:
- Removes pathway reject and yield reductions and simplifies residual validation.
- Updates mass-flow tests and routing helpers for the single diversion result.
- Documents the resulting landfill and methane reductions.
| File | Description |
|---|---|
tests/test_adst_city_mass_flow.py |
Checks full requested diversion shares and mass balance. |
tests/test_adst_city_diversion_routing.py |
Adapts the helper to the single DivsDF return value. |
SWEET_python/advanced_dst_city.py |
Removes pathway losses and simplifies residual calculations. |
changelog/2026-10.md |
Records model-output changes and unchanged behavior. |
Review effort: Balanced
Comment on lines
+229
to
+251
| def test_recycling_and_digestion_keep_everything_they_are_sent(): | ||
| """The no-reject rule holds for every pathway, recycling's per-material yields | ||
| included, not only for compost.""" | ||
| request = _request( | ||
| [_landfill()], | ||
| (1.0,), | ||
| diversion={ | ||
| "recycling": {y: 0.15 for y in YEARS}, | ||
| "anaerobic": {y: 0.05 for y in YEARS}, | ||
| }, | ||
| food_prevention=0.5, | ||
| ) | ||
| flow = run_advanced_dst_city(request, with_mass_flow=True)["mass_flow"]["scenario"] | ||
| net_generated = float( | ||
| flow["generated"].loc[AFTER].sum() - flow["prevented"].loc[AFTER].sum() | ||
| ) | ||
|
|
||
| assert float(flow["diverted"]["recycling"].loc[AFTER].sum()) == pytest.approx( | ||
| 0.15 * net_generated | ||
| ) | ||
| assert float(flow["diverted"]["anaerobic"].loc[AFTER].sum()) == pytest.approx( | ||
| 0.05 * net_generated | ||
| ) |
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.

User story
As an advanced DST user, I want a diversion share to mean what actually happens, so that "compost 10% of our waste" composts 10%, and every number I type or read refers to the same thing.
What changes
advanced_dst_city._diverted_massesstops applying reject and yield rates. Before:non_compostable_not_targeted, thenunprocessable);All of that went back to the landfills. So a city told to compost 10% composted about 8.7%, and the landfills received the rest on top of their stated shares. Anaerobic digestion already kept everything.
Now every pathway keeps everything it is sent.
_diverted_massesreturns oneDivsDF. The separate gross figure was there to catch over-diversion before rejects. It is now the same thing, soover_diversionmeasures the residual directly.Effect. A city of 1 Mt a year with no gas capture, in 2040:
Unchanged:
City's rates.city_params.pyis untouched.combusts) in the advanced DST still buriescombustion_reject_rate. That is a separate rate, whichmainalready set to 0 in Waste sent to incineration stops producing methane #100; it arrives here with the next merge ofmainintoam-waste-flow. Zeroing it on this branch now would make an incinerator's Sites-tab intake read 0 t, because the mass flow reports what a site buries rather than what it takes in.Why
Hugh's call, 2026-10-28: rejects are minor, and they made every share a user states mean something smaller than what they typed. Removing them also clears two earlier problems:
Acceptance criteria
Citypaths are unchanged.Testing
pytest -m "not integration": 659 passed.test_diverted_is_the_whole_requested_sharereplaces the test that required rejects.test_recycling_and_digestion_keep_everything_they_are_sentcovers the other pathways.Definition of Done
Acceptance criteria met · tests and checks pass · changelog updated · reviewed and merged (merge commit).
🤖 Generated with Claude Code