Skip to content

[TEST] LinearResamplerAlign: pin single-spike / zero-width-interval edge cases (#9460) - #9526

Merged
timosachsenberg merged 1 commit into
OpenMS:developfrom
timosachsenberg:test/9460-linearresampleralign-spike
Jun 16, 2026
Merged

timosachsenberg merged 1 commit into
OpenMS:developfrom
timosachsenberg:test/9460-linearresampleralign-spike

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds three [EXTRA] regression sections to LinearResamplerAlign_test.cpp exercising raster() on degenerate inputs:

  1. Single data point (start_pos == end_pos, a zero-width resampling interval) → exactly one output point carrying the full intensity.
  2. Isolated off-grid spike (m/z 2.25, flanked by zeros) → area preserved, split across its two grid neighbours, not amplified beyond the original, and not leaked to the far ends of the spectrum.
  3. Coincident raw m/z (two points at the same m/z = a zero-width interval) → total intensity conserved, every value finite (no NaN/Inf).

Why

This closes the §7 [AUTO] gap in the OpenMS 3.6.0 pre-release testing plan (#9460):

LinearResampler spike (#9127, folded into LinearResamplerAlign) — add a single-spike / zero-width-interval case. Pass: no spurious spike; intensity conserved.

The existing sections only resample well-behaved multi-point spectra; none exercised a lone spike or coincident m/z. raster() is area-preserving because it distributes each raw point's intensity onto its two grid neighbours and divides by the grid spacing (dist_left + dist_right), never by the raw-point gap — so a zero-width interval in the input must not divide by zero or fabricate a spurious peak. These tests pin exactly that contract.

Test plan

Tests only — no production code changed. Verified locally three ways:

  • -fsyntax-only clean, then full target build green;
  • the test runs PASSED (all three new sections pass);
  • expected values cross-checked against an independent Python port of the raster algorithm (single point → intensity 7 at one bin; [email protected] → 2.5/2.5 split across m/z 2.0/2.5, sum 5, nothing far; coincident m/z → sum 10, all finite).

Part of #9460. Follows #9524 (native-ID parser) and #9525 (copy independence).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added three new regression test scenarios to ensure stability and accuracy under various boundary and edge-case conditions.

…dge cases (OpenMS#9460)

Adds regression guards for the folded LinearResampler spike fix (OpenMS#9127). The
area-preserving raster() distributes each raw point's intensity onto its two
grid neighbours and divides by the grid spacing (never by the raw-point gap),
so a lone spike or coincident (zero-width interval) raw points must conserve
total intensity, never be amplified into a spurious larger peak, and never
produce NaN/Inf. The existing sections never exercised these degenerate inputs.

Three [EXTRA] sections on raster():
- single data point (start_pos == end_pos): one output point carrying all intensity
- isolated off-grid spike: area preserved, split across the two neighbours,
  not amplified, and not leaked to the far ends of the spectrum
- coincident raw m/z (zero-width interval): total intensity conserved, all finite

Verified: builds clean and the test runs PASSED.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

@timosachsenberg The following names might be missing from the AUTHORS file:

  • Timo Sachsenberg

Please consider applying the following patch:

--- AUTHORS	2026-06-15 15:14:34.688853578 +0000
+++ AUTHORS.new	2026-06-15 15:14:40.006440136 +0000
@@ -23,8 +23,8 @@
  - Chirag Dave
  - Chris Bauer
  - Chris Bielow
- - Christie Mathews
  - Christian Ehrlich
+ - Christie Mathews
  - Clemens Groepl
  - Cornelia Friedle
  - Daniel Jameson

@coderabbitai

coderabbitai Bot commented Jun 15, 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

Run ID: 640b134c-6534-4e85-9972-6be63bfb82b8

📥 Commits

Reviewing files that changed from the base of the PR and between aacd941 and 7684f24.

📒 Files selected for processing (1)
  • src/tests/class_tests/openms/source/LinearResamplerAlign_test.cpp

📝 Walkthrough

Walkthrough

Three regression test sections are added to LinearResamplerAlign_test.cpp for raster() edge cases: a degenerate single-point resampling interval, an isolated intensity spike (conservation, localization, no amplification), and coincident raw input points (zero-width interval, no NaN/Inf). A <cmath> include is added to enable std::isfinite.

Changes

LinearResamplerAlign Regression Tests

Layer / File(s) Summary
Edge-case regression tests for raster()
src/tests/class_tests/openms/source/LinearResamplerAlign_test.cpp
Adds <cmath> include and three new START_SECTION blocks covering: (1) single degenerate interval producing exactly one output point, (2) isolated spike conserving total intensity, remaining localized, and avoiding spurious amplification, (3) coincident zero-width raw points conserving intensity and producing only finite output values.

Possibly Related PRs

  • OpenMS/OpenMS#9153: Directly related — refactors/removes LinearResampler in favor of LinearResamplerAlign and modifies raster() behavior, which is exactly what the new regression tests guard against.

Poem

🐇 Hop, hop, through the spectral domain,
Where spikes must conserve and not go insane,
No NaN shall escape this raster brigade,
No Inf shall lurk where intensities fade.
The rabbit has tested each degenerate case —
The resampler runs true, at its elegant pace! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding regression tests for LinearResamplerAlign edge cases involving single spikes and zero-width intervals.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

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.

1 participant