Repository navigation
A listed landfill's share a rounding error below zero sends no negative waste - #96
Merged
HughRunyan merged 1 commit intoOct 20, 2026
Merged
Conversation
…ve waste Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
The localized fix addresses the reported failure and includes regression coverage for both variants, with no unresolved findings.
No open issues 🎉
What changed in this PR
Fixes negative waste routing in advanced DST city requests with other_landfills.
Changes:
- Clips tolerated listed shares to [0, 1] before calculating remaining waste.
- Adds regression coverage for baseline and scenario routing.
- Documents the correction in the changelog.
| File | Description |
|---|---|
| tests/test_adst_city_other_landfills.py | Checks that tolerated negative shares produce no negative waste. |
| SWEET_python/advanced_dst_city.py | Clips shares while preserving validation and normalization. |
| changelog/2026-10.md | Documents the routing fix. |
Review effort: Balanced
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.
Environment
SWEET_python
am-waste-flow,advanced_dst_city._with_other_landfills(added by #90).Reproduction
A city-level ADST request with one listed landfill at share
-0.01, plusother_landfills.Expected vs actual
_validate_share_rangetolerates shares down to −0.02, and the routing used them as given. The split became[-0.01, 1.01]. For 10,000 t of residual waste, that buried −100 t at the listed site and 10,100 t at other landfills.Copilot flagged it on #95 (whose diff showed #90's code at the time). It was never fixed in #90.
Fix
Clip tolerated shares to [0, 1] before working out what other landfills take. A regression test fails on
am-waste-flowand passes here.Acceptance criteria
pytest -m "not integration": 610 passed.Definition of Done
Acceptance criteria met · tests pass · changelog updated · reviewed & merged.
🤖 Generated with Claude Code