Repository navigation
Refactor MzPAF: rename isStandardFragmentIon, make toString total - #10197
Merged
Merged
Conversation
The d/v/w enumerators were appended after UNKNOWN so that every pre-existing MzPAFIonSeries value stays stable, which matters because pyOpenMS exposes the enum arithmetically (nb::is_arithmetic). Without a note, the odd-looking order invites a later reordering that would silently shift those values. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PjgX4heZ2Kv2QGd24mFL82
toString() threw Exception::InvalidParameter for a satellite subtype that mzPAF does not allow, while writing an equally invalid UNKNOWN series as '?' without complaint -- two contracts in one function. The throw also escaped through three callers that should not throw: operator<<(), so a log line or a failing TEST_EQUAL's printer could raise; toString(MzPAFPeakAnnotations), where one bad entry discarded the whole list; and toPeakAnnotation(). Drop the non-conformant subtype when serialising instead, matching the UNKNOWN precedent, and leave rejection to isValid(), which still refuses these annotations. Tests assert the lenient output in place of the exception and cover streaming an invalid annotation. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PjgX4heZ2Kv2QGd24mFL82
The predicate now returns true for d/v/w, whose calculateTheoreticalMZ() returns std::nullopt by design, so the name promised more than it delivers: the natural caller pattern `if (isStandardFragmentIon(s)) mz = *calculateTheoreticalMZ(...)` would dereference an empty optional. The documentation already said "peptide"; the name now agrees, and a @note spells out that a true result does not imply a computable mass. Renaming a public static is an API break, but MzPAF is unreleased (3.6.0, under development) and has no callers outside the class, its test and the bindings, so no deprecation shim is warranted. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PjgX4heZ2Kv2QGd24mFL82
…g change The binding diff was 87 insertions and 58 deletions, nearly all of it reindentation of MzPAFAnnotation, MzPAFIonSeries and MzPAF blocks the change never touched, which buried the handful of lines that actually matter. Restore the surrounding formatting so the diff carries only the substantive edits: the satellite_subtype field, the D/V/W enum values, the two docstring lines, the isPeptideFragmentIon rename and the missing newline at end of file. Same resulting binding, 8 insertions and 2 deletions instead of 145 changed lines. Reformatting this file is worth doing, but as its own commit. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PjgX4heZ2Kv2QGd24mFL82
Contributor
|
Warning Review limit reachedNext included review available in 1 minute. View limit detailsLimit details: You’ve used all 4 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Sep 19, 2026
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.
Description
Follow-up cleanups to the MzPAF satellite-ion support merged in #10180. Only point 2 changes behaviour.
Rename
isStandardFragmentIon()toisPeptideFragmentIon(). The predicate returns true for d/v/w, whosecalculateTheoreticalMZ()returnsstd::nulloptby design, so the old name promised more than it delivers — the natural caller patternif (isStandardFragmentIon(s)) mz = *calculateTheoreticalMZ(...)would dereference an empty optional. The documentation already said "peptide"; the name now agrees, and a@noterecords that a true result does not imply a computable mass. This is a public API break, but MzPAF is unreleased (3.6.0, under development) and has no callers outside the class, its test and the bindings, so no deprecation shim is warranted.Make
MzPAF::toString()total. It threwException::InvalidParameterfor a satellite subtype mzPAF does not allow, while writing an equally invalidUNKNOWNseries as?without complaint — two contracts in one function. The throw also escaped through three callers that should not throw:operator<<(), so a log line or a failingTEST_EQUAL's printer could raise;toString(MzPAFPeakAnnotations), where one bad entry discarded the whole list; andtoPeakAnnotation(). It now drops the non-conformant subtype instead, mirroring theUNKNOWNprecedent. Rejecting such annotations staysisValid()'s job, which still refuses them.Revert the clang-format churn in
bind_chemistry.cpp. The binding diff in Support mzPAF satellite-ion annotations (d, v, w) #10180 was 87 insertions and 58 deletions, nearly all reindentation of blocks the change never touched, which buried the handful of lines that mattered. Restoring the surrounding formatting leaves only the substantive edits: measured against the merge base, that file is now 8 insertions and 2 deletions rather than 145 changed lines. Reformatting it is worth doing, but as its own commit. One trailing space on the restoredMzPAFAnnotationline is stripped rather than faithfully reintroduced, sogit diff --checkstays clean.Tests updated to the new contract. The
TEST_EXCEPTION/pytest.raisescases ontoString()become assertions on the lenient output, plus a new case streaming an invalid annotation throughoperator<<().Validation
contribsubmodule, no system Boost). Verification so far is limited to: exhaustive grep confirming the rename leaves no stale references,python -m py_compileon the changed test module, andgit diff --check.CI on this PR is the first real build and test run — please weigh it over the checklist below.
Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01PjgX4heZ2Kv2QGd24mFL82