Skip to content

[TEST,CLEANUP] Cover SignalToNoiseEstimatorMedianRapid empty-window fallback, drop unused boost includes - #9994

Merged
timosachsenberg merged 1 commit into
developfrom
claude/openms-pr-9782-review-hqz4oz
Aug 29, 2026
Merged

timosachsenberg merged 1 commit into
developfrom
claude/openms-pr-9782-review-hqz4oz

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Two independent follow-ups to the review of #9782, split out so they can land on their own.

Both changes were written against develop and hold before and after the speedup in #9782, so they are regression guards rather than a codification of new behaviour. Merging them first gives #9782 a safety net for the exact code path it reworks.

1. Test coverage for the zero-median fallback

computeNoiseInWindows_ imputes (mean + 3*stdev)/60 whenever a window's median is exactly 0. No existing test ever executed that branch: the class test's intensity array contains no zeros and its m/z grid is uniform, so no window is ever empty. The whole fallback path could be broken and CI would stay green.

Two cases are added to the existing estimateNoise section:

  • m/z gap — points at 200–290 and 400–490 with window_length = 100, leaving [300, 400) without any data point. computeMedian_ returns 0 and the imputed value 0.23528073283 is stored. The odd-grid value and get_noise_value at the same position are asserted too, so the even/odd averaging over an imputed window is covered.
  • all-zero intensities — here the imputed fallback is itself 0.0. This distinguishes a fallback cache keyed on a flag from one keyed on the value: a if (fallback == 0.0) sentinel would silently recompute mean/stdev for every window and nothing would catch it. It also pins get_noise_value clamping to 1.0, so clients dividing by the noise estimate stay safe.

This matters for #9782, which makes that branch stateful and cached.

2. Remove unused boost includes

No boost::accumulators symbol appears anywhere in the translation unit — mean and stdev are computed with std::accumulate / std::inner_product. The boost/serialization/array_wrapper.hpp include and its OPENMS_BOOST_VERSION_MINOR guard (the issue #2790 workaround) existed only to support the accumulators headers, so all four go.

⚠️ Those headers were also transitively supplying <cmath>. Removing them without compensating breaks the build on the std::sqrt used for the stdev:

error: 'sqrt' is not a member of 'std'; did you mean 'sort'?

So <cmath> is added explicitly, along with <iterator> for std::distance / std::advance / std::iterator_traits, which were likewise only incidentally available. The translation unit is now self-contained.

Verification

Compiled the real translation unit against the real header with -Wall -Wextra — clean, no warnings — then linked it into a harness running the new assertions plus all 25 pre-existing ones from the class test, against this branch's (i.e. develop's) implementation:

empty-window block:    5/5 OK
all-zero block:        2/2 OK
existing assertions:  25/25 OK
ALL PASS (0 failures)

The same 32 assertions also pass against the #9782 head, which is what makes these safe to merge in either order.

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

🤖 Generated with Claude Code

https://claude.ai/code/session_01PfBYxKS6C1aUUhgSUSycQA


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved signal-to-noise estimation when data contains gaps, ensuring empty measurement windows receive a valid fallback estimate.
    • Improved handling of spectra with entirely zero intensities, preventing invalid noise values and applying the minimum supported noise level.
  • Tests

    • Added coverage for gapped m/z data and all-zero intensity arrays to verify reliable noise estimation in these edge cases.

Follow-up to review feedback on the SignalToNoiseEstimatorMedianRapid
speedup.

Add test coverage for the zero-median fallback path. The existing test
data has no zero intensities and a uniform m/z grid, so no window is ever
empty and the fallback branch was never executed by any test. Two cases
are added:

- An m/z gap that leaves the window [300, 400) without any data point, so
  computeMedian_ returns 0 and the imputed (mean + 3*stdev)/60 value is
  used.
- An all-zero intensity array, where the imputed fallback is itself 0.
  This pins down the cache flag: a cache keyed on the value rather than
  on a separate bool would silently recompute for every window.

Both cases were verified to produce identical results before and after
the speedup change, so they are regression guards rather than a
codification of new behaviour.

Remove the unused boost includes. No boost::accumulators symbol appears
in the translation unit; mean and stdev are computed with
std::accumulate and std::inner_product. The serialization/array_wrapper
include and its OPENMS_BOOST_VERSION_MINOR guard existed only to support
the accumulators headers.

Those headers were also transitively supplying <cmath>, so add it (and
<iterator>, for std::distance/advance/iterator_traits) explicitly to keep
the translation unit self-contained.

Co-Authored-By: Claude <[email protected]>
Claude-Session: https://claude.ai/code/session_01PfBYxKS6C1aUUhgSUSycQA
@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ae2aaaeb-5c6d-4ed5-b797-4edb209db46f

📥 Commits

Reviewing files that changed from the base of the PR and between b273e2b and 9ec5f3e.

📒 Files selected for processing (2)
  • src/openms/source/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimatorMedianRapid.cpp
  • src/tests/class_tests/openms/source/SignalToNoiseEstimatorMedianRapid_test.cpp

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The change removes unused Boost includes from SignalToNoiseEstimatorMedianRapid.cpp and adds tests for empty m/z windows and all-zero intensities. The tests verify fallback calculation, median results, averaging, and minimum noise clamping.

Changes

Median noise estimation

Layer / File(s) Summary
Standard-library cleanup and fallback edge cases
src/openms/source/PROCESSING/NOISEESTIMATION/SignalToNoiseEstimatorMedianRapid.cpp, src/tests/class_tests/openms/source/SignalToNoiseEstimatorMedianRapid_test.cpp
The implementation uses standard-library includes instead of Boost headers. Tests verify fallback estimation for empty windows and clamping for all-zero intensities.

Poem

A rabbit checks the silent span,
Where no m/z points cross the plan.

Zero signals rest in rows,
The fallback faithfully still flows.
Medians hop, and bounds stay bright.
Noise is clamped to one at night.

Merge Risk: ⚪ Minimal · up to 9ec5f

This change adds regression coverage for empty-window noise handling and makes the implementation's standard-library dependencies explicit without changing product behavior. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes both main changes: regression coverage for the empty-window fallback and removal of unused Boost includes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/openms-pr-9782-review-hqz4oz

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@timosachsenberg
timosachsenberg merged commit e641d34 into develop Aug 29, 2026
35 checks passed
@timosachsenberg
timosachsenberg deleted the claude/openms-pr-9782-review-hqz4oz branch August 29, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants