Fix map_peaks aborting on the first unmapped compound#26
Merged
Conversation
map_peaks() used `break` when a requested compound had no peak within loc_tolerance, which silently skipped every compound listed after the missing one and raised "No peaks could be properly mapped!" when the first compound was the missing one. Change `break` to `continue` so all present compounds are mapped and each absent compound still warns. Adds a regression test where a missing compound precedes valid ones. Fixes #23 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #26 +/- ##
=======================================
Coverage 97.12% 97.12%
=======================================
Files 3 3
Lines 556 556
=======================================
Hits 540 540
Misses 16 16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Use a set comparison for mapped compounds (robust to peak count and lexicographic ordering, e.g. compound_10 vs compound_2) and scope the warning assertion to the specific "No peak found for absent" message rather than matching any warning. Co-Authored-By: Claude Opus 4.8 <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.
Summary
This PR addresses #23.
Chromatogram.map_peaks()stopped mapping as soon as it hit a requested compound with no peak withinloc_tolerance. Because the loop usedbreak, every compound listed after the missing one was silently skipped — and if the first compound was the missing one,mapperstayed empty and the method raisedValueError("No peaks could be properly mapped!")even when all the other compounds were present in the chromatogram.This was reported in #23 with a reproducing example.
Root cause
In
map_peaks(hplc/quant.py), the "no peak found" branch exited the whole loop:Fix
Change
breaktocontinueso each present compound is mapped and each absent compound still records an entry inunmappedand emits its warning.Tests
main, passes here.)Risk
Minimal — single-token logic change endorsed by the reporter and maintainer in #23. Existing
test_map_peakscontinues to pass (its missing-compound case is last in the dict, so it was unaffected by the original bug).