Repository navigation
[FIX,TEST] FuzzyStringComparator: NaN is not equal to everything (#9859) - #9861
Conversation
Fixes #9859. Every comparison against NaN is false, so nothing in the number-vs-number branch could reject one: 'absdiff > absdiff_max_', 'ratio < 0', 'ratio < 1' and finally 'ratio > ratio_max_' -- the sole gate to reportFailure_ -- were all false, and the pair fell through to the end of the branch and was accepted. 'nan' therefore compared equal to ANY number, and +inf compared equal to -inf because their ratio is NaN as well. The consequence is not subtle: a value that regressed to NaN was invisible to every file comparison in the suite -- the 778 FuzzyDiff comparisons of the TOPP tests and TEST_FILE_EQUAL in the class tests -- whatever the other file held. That is the direction a real regression travels: the tool emits NaN, the reference holds a legitimate number, and the test stays green. Non-finite pairs are now decided by category before the arithmetic runs: the same non-finite value on both sides is equal (a reference may legitimately contain 'nan', and two NaNs never reach the equality fast path because NaN != NaN), and anything else is reported. Deliberately surgical: an infinity against a finite number is ordered and was already reported correctly -- by the ratio test for +inf, by the sign test for -inf -- so it keeps its existing path and message. Only the outcomes that were wrong change, which also keeps the failure text and the running max statistics unchanged for everything that already worked. Full suite: 2811 tests, no new failures. The 9 that fail here are environmental and reproduce identically without this change (6x CometAdapter version string, PercolatorAdapter binary numerics, Doxygen HAVE_DOT, and ThermoRawFile which needs DOTNET_ROOT). In particular the four reference files that carry 'nan' on the reference side -- MzTabExporter_3_output.mzTab with 1268 of them, TextExporter_2/_7 with 678 between them -- still pass, because those are nan-against-nan and remain equal under the new rule. So the hole was real but is not currently masking a live regression on this platform. The new class-test section was confirmed to fail without the fix, at exactly the six assertions that correspond to the defect. It does NOT fail at 'nan' vs '0.0' or at an infinity vs a finite number, because those were already reported correctly -- which is the evidence that the change is as narrow as intended. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01VcFtJVe1PcMsBzMnnnpWBJ
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesNon-finite comparison handling
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openms/source/CONCEPT/FuzzyStringComparator.cpp`:
- Around line 354-359: Update the infinite-value classification in
FuzzyStringComparator.cpp around the existing comparison logic to reject any
pair where either operand is infinite, after equality and NaN checks, while
preserving the existing differing-sign message for two infinities. In
src/tests/class_tests/openms/source/FuzzyStringComparator_test.cpp lines
473-476, add the reverse-order assertion that equal("x 5.0", "x -inf") is false.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4a6c24e2-c594-463e-8fea-0d7b623cfb04
📒 Files selected for processing (3)
CHANGELOGsrc/openms/source/CONCEPT/FuzzyStringComparator.cppsrc/tests/class_tests/openms/source/FuzzyStringComparator_test.cpp
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
timosachsenberg
left a comment
There was a problem hiding this comment.
looks correct to me
Three CHANGELOG entries already document their change in full but were missing the trailing PR citation: consensusXML protein-group quantity round-tripping (#9844), the FuzzyStringComparator NaN-equality fix (#9859, #9861), and the "five more Parquet writers left a partial file behind" fix (#9862). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YAD9pD1nBputTVhzddmCj5
Fixes #9859.
The defect
Every comparison against
NaNis false, so nothing inFuzzyStringComparator's number-vs-number branch could reject one::328if (element_1_.number == element_2_.number)— false, so no early accept;:347is_absdiff_small_ = (absdiff <= absdiff_max_allowed_)—absdiffisNaN, sofalse;:376double ratio = element_1_.number / element_2_.number;—NaN;:378if (ratio < 0)— false, so the "different signs" failure is skipped;:387if (ratio < 1)— false, so the reciprocal is not taken;:396if (ratio > ratio_max_)— false, and this is the sole gate toreportFailure_.Control reached the end of the branch and the pair was accepted.
nantherefore compared equal to any number, and+infcompared equal to-infbecause their ratio isNaNtoo.The consequence is not subtle: a value that regressed to
NaNwas invisible to every file comparison in the suite — the 778 FuzzyDiff comparisons in the TOPP tests andTEST_FILE_EQUALin the class tests — whatever the other file held. That is precisely the direction a real regression travels: the tool emitsNaN, the reference holds a legitimate number, the test stays green.The fix
Non-finite pairs are decided by category before the arithmetic runs:
nannaninfinf-inf-infnan5.05.0nannan±infinf-infinf/-inf5.0nanabc1.02.0Two NaNs are equal on purpose — a reference may legitimately contain
nan, and they never reach the==fast path sinceNaN != NaN.Deliberately surgical. An infinity against a finite number is ordered and was already reported correctly — by the ratio test for
+inf, by the sign test for-inf— so it keeps its existing path and message. Only the outcomes that were wrong change, which also leaves the failure text and the running-max statistics untouched for everything that already worked.Blast radius: none
Full suite: 2811 tests, no new failures. The 9 that fail in this environment reproduce identically with the fix reverted — 6× CometAdapter version string, PercolatorAdapter binary numerics, Doxygen
HAVE_DOT, andThermoRawFile_testwhich needsDOTNET_ROOT. I verified this by reverting the change, rebuilding, and re-running exactly those tests rather than assuming.The four reference files carrying
nanon the reference side still pass, because those arenan-against-nanand remain equal under the new rule:nanoccurrencesMzTabExporter_3_output.mzTabTextExporter_2_consensus_tsv.tsvTextExporter_2_consensus_features.wsvTextExporter_7_consensus_tsv.tsvSo the hole was real, but it is not currently masking a live regression on this platform and configuration. That is worth stating plainly: the value of this change is preventing the next one, not repairing an existing wrong result.
Tests
The new class-test section was confirmed to fail without the fix, at exactly the six assertions corresponding to the defect. It does not fail at
nanvs0.0(already caught pre-fix via the zero branch) or at an infinity vs a finite number (already ordered correctly) — which is the evidence that the change is as narrow as claimed.It also pins that a
NaNelsewhere on a line does not make the rest of that line permissive.Caveat I could not settle locally
Non-finite formatting is platform-dependent —
nanvs-nanvs1.#IND— which is whySVOutStream::writeValueOrNanexists at all. Everything above is Linux/gcc. If a Windows or macOS runner formats a non-finite value differently from what a reference file records, this change will surface it as a failure where it was previously swallowed. That would be the fix working as intended, but it is the most likely source of CI noise on this PR and worth watching.Related
TOPP_ProteinQuantifier_29_out2works around the limitation with a textual assertion, which becomes unnecessary once this lands.🤖 Generated with Claude Code
https://claude.ai/code/session_01VcFtJVe1PcMsBzMnnnpWBJ
Summary by CodeRabbit
Bug Fixes
Tests
Documentation