Repository navigation
Deleted LinearResampler - #9153
Deleted LinearResampler #9153
Conversation
|
@LuBox2K The following names might be missing from the
Please consider applying the following patch: --- AUTHORS 2026-04-15 12:27:20.613546199 +0000
+++ AUTHORS.new 2026-04-15 12:27:24.757258956 +0000
@@ -5,18 +5,19 @@
The following authors contributed to OpenMS at some point. For the
authors contributing to a specific piece of code, please refer to
the authors tag in the respective file header.
+ - Michael R. Crusoe
- Achal Bajpai
- Aditya Muzumdar
- Ahmed Khalil
- Alen Saric
- Alexandra Scherbart
- - Axel Walter
- Alexandra Zerck
- Amanda Wein
- Andreas Bertsch
- Andreas Simon
- Anton Kriese
- Anton Pervukhin
+ - Axel Walter
- Bastian Blank
- Chenghao Zhu
- Chirag Dave
@@ -27,8 +28,8 @@
- Cornelia Friedle
- Daniel Jameson
- Darren Kessner
- - David Wojnar
- David Voigt
+ - David Wojnar
- Dhanmoni Nath
- Dilek Dere
- Dimitri Schachmann
@@ -55,14 +56,14 @@
- Jang Jang Jin
- Jeremi Maciejewski
- Jihyung Kim
- - Johan Teleman
- Johannes Junker
- Johannes Veit
- Johannes von Kleist
+ - Johan Teleman
- Joshua Charkow
- - Julia Thueringer
- Juliane Schmachtenberg
- Julianus Pfeuffer
+ - Julia Thueringer
- Justin Sing
- Katharina Albers
- Khue Nguyen
@@ -74,6 +75,7 @@
- Leon Bichmann
- Leon Kuchenbecker
- Lucia Espona
+ - luik42
- Luis Jacob Keller
- Lukas Mueller
- Lukas Zimmermann
@@ -86,7 +88,6 @@
- Matteo Pilz
- Matthew The
- Matthias Bernt
- - Michael R. Crusoe
- Michał Startek
- Mohamed Ali
- Nico Pfeifer
@@ -112,11 +113,11 @@
- Sven Nahnsen
- Svetlana Kutuzova
- Swenja Wagner
- - Taraneh Strunk
- Tapasweni Pathak
+ - Taraneh Strunk
+ - Till Englert
- Timo Sachsenberg
- Tinatin Kasradze
- - Till Englert
- Tom David Müller
- Tom Lukas Lankenau
- Tom Waschischeck |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe standalone LinearResampler class and its global instances were removed. Functionality was consolidated into LinearResamplerAlign (now inheriting DefaultParamHandler and ProgressLogger), which gained spacing verification and an experiment-level rasterExperiment with progress reporting. Examples, docs, bindings, tests, and CMake lists were updated accordingly. Changes
Sequence Diagram(s)sequenceDiagram
rect rgba(200,200,255,0.5)
participant Tool as Resampler (topp/Resampler)
participant Align as LinearResamplerAlign
participant Exp as MSExperiment/PeakMap
participant Logger as ProgressLogger
end
Tool->>Align: construct & setParameters(param)
Tool->>Align: rasterExperiment(exp)
Align->>Logger: startProgress(total_spectra)
loop per spectrum
Align->>Exp: get spectrum[i]
Align->>Align: verifySpacing_(spectrum)
Align->>Align: raster(spectrum)
Align->>Logger: setProgress(i)
end
Align->>Logger: endProgress()
Align-->>Tool: return
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/pyOpenMS/bindings/bind_misc.cpp (1)
2646-2654:⚠️ Potential issue | 🟠 Major
LinearResamplerAlignbinding is missing inheritedDefaultParamHandlerinterface andrastermethodThe test in
src/pyOpenMS/tests/unittests/test000.py:1862-1866explicitly expectsgetDefaults()andraster()methods onLinearResamplerAlign, but the current binding at line 2646 neither declaresDefaultParamHandleras a base class nor exposes therastermethods. This breaks the test and removes user-visible API surface.Additionally, per coding guidelines, the binding lacks copy constructor,
__copy__, and__deepcopy__methods.Proposed fix
- auto linearresampleralign_class = nb::class_<OpenMS::LinearResamplerAlign>(m, "LinearResamplerAlign", + auto linearresampleralign_class = nb::class_<OpenMS::LinearResamplerAlign, OpenMS::DefaultParamHandler>(m, "LinearResamplerAlign", R"doc( Linear Resampling of raw data with alignment LinearResamplerAlign )doc") .def(nb::init<>()) + .def(nb::init<const OpenMS::LinearResamplerAlign &>()) + .def("__copy__", [](const OpenMS::LinearResamplerAlign& self) { return OpenMS::LinearResamplerAlign(self); }) + .def("__deepcopy__", [](const OpenMS::LinearResamplerAlign& self, nb::dict) { return OpenMS::LinearResamplerAlign(self); }, "memo"_a) + .def("raster", [](OpenMS::LinearResamplerAlign& self, OpenMS::MSSpectrum& spectrum) { self.raster(spectrum); }, "spectrum"_a, "Resamples a single spectrum") .def("rasterExperiment", [](OpenMS::LinearResamplerAlign& self, OpenMS::MSExperiment& exp) { return self.rasterExperiment(exp); }, "exp"_a, "Resamples the data in an MSExperiment") ; def_ProgressLogger<OpenMS::LinearResamplerAlign>(linearresampleralign_class);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/pyOpenMS/bindings/bind_misc.cpp` around lines 2646 - 2654, The LinearResamplerAlign binding needs to inherit DefaultParamHandler, expose its raster overloads, and add copy semantics: modify the nb::class_ declaration for OpenMS::LinearResamplerAlign to include nb::base<OpenMS::DefaultParamHandler>(), add bindings for both raster methods (e.g., raster(OpenMS::MSChromatogram&) and raster(OpenMS::MSExperiment&)) in addition to the existing rasterExperiment, and add the copy constructor and Python helpers by binding the copy ctor and methods __copy__ and __deepcopy__ (forwarding to the copy ctor) so getDefaults()/DefaultParamHandler methods and proper copy behavior are available; keep def_ProgressLogger<OpenMS::LinearResamplerAlign>(...) as-is.
🧹 Nitpick comments (5)
src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h (3)
339-344: Misplaced member variable comment.The comment "Spacing of the resampled data" on line 343 appears to describe
spacing_but is positioned aboveppm_. Consider moving it to the correct location.♻️ Suggested fix
protected: + /// Spacing of the resampled output peaks double spacing_; - /// Spacing of the resampled data + /// Whether spacing is in ppm or Th bool ppm_;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h` around lines 339 - 344, The doc comment "Spacing of the resampled data" is attached to the wrong member; move that comment so it documents spacing_ (double spacing_) rather than ppm_ (bool ppm_). In the class LinearResamplerAlign (header OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h) adjust the member declarations so spacing_ is immediately preceded by the "Spacing of the resampled data" comment and leave ppm_ with an appropriate or no comment.
112-112: Inconsistent lambda syntax acrossverifySpacing_calls.Line 112 uses C++20 explicit template lambda syntax
[]<typename PeakTypeIterator>(...), while line 155 uses a simpler generic lambda[](auto x){...}. For consistency and simplicity, consider using the same style across all call sites.♻️ Suggested fix
- verifySpacing_(first, last, []<typename PeakTypeIterator>(PeakTypeIterator x){return x->getPos();}); + verifySpacing_(first, last, [](auto x){return x->getPos();});🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h` at line 112, The two calls to verifySpacing_ use inconsistent lambda forms; replace the explicit template lambda in the call that currently uses []<typename PeakTypeIterator>(PeakTypeIterator x){ return x->getPos(); } with a generic lambda using auto (i.e. [](auto x){ return x->getPos(); }) so both verifySpacing_ invocations use the same simple generic-lambda style; update the call site that references PeakTypeIterator/getPos to use the [](auto x){...} form.
386-406: Inconsistent brace style and potential improvement for iterator handling.Per coding guidelines, braces should be on their own lines. Additionally, the loop condition could be made more consistent with line 390.
♻️ Suggested improvements
template <typename PeakTypeIterator> void verifySpacing_(PeakTypeIterator it, PeakTypeIterator end, auto access) { if (it == end || std::next(it) == end) return; double min_dist = std::numeric_limits<double>::infinity(); double current_dist{}; - while (it != end-1) + while (std::next(it) != end) { current_dist = (access(std::next(it)) - access(it)); if (min_dist > current_dist) min_dist = current_dist; ++it; } - if (spacing_ < min_dist){ - OPENMS_LOG_WARN << "you have chosen a resampling rate of: " << spacing_ <<\ - "\n this is smaller than the smallest Distance (" << min_dist << ") between Datapoints.\n\ - Since this approximates the dead time of the Detector this can result in fake peaks"; - } + if (spacing_ < min_dist) + { + OPENMS_LOG_WARN << "Resampling spacing (" << spacing_ + << ") is smaller than the smallest distance between data points (" + << min_dist << "). This may result in spurious peaks.\n"; + } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h` around lines 386 - 406, The verifySpacing_ helper uses inconsistent brace placement and an unsafe loop condition; update the function (verifySpacing_) to place opening braces on their own lines per style, and replace while (it != end-1) with while (std::next(it) != end) (or equivalently while (it + 1 != end) for random-access) to avoid iterator arithmetic on non-random-access iterators; keep the initial guard (if (it == end || std::next(it) == end) return) and the access(...) distance calculation unchanged, and ensure the OPENMS_LOG_WARN call remains after the loop with its braces on separate lines as well.src/pyOpenMS/tests/unittests/test000.py (1)
1865-1866: Consider adding one behavioral assertion forrasterExperiment.Line 1865 and Line 1866 currently validate method presence only. A tiny round-trip/shape-intensity assertion would better catch binding regressions.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/pyOpenMS/tests/unittests/test000.py` around lines 1865 - 1866, Create a small behavioral round-trip for LinearResamplerAlign.rasterExperiment: instantiate pyopenms.LinearResamplerAlign(), build a tiny pyopenms.MSExperiment with one spectrum containing a single peak (set m/z and intensity), assign it to lr.rasterExperiment, then retrieve lr.rasterExperiment and assert the spectrum count and the first spectrum's peak m/z/intensity match the original; reference LinearResamplerAlign, rasterExperiment, MSExperiment and getNrSpectra()/get_peaks()/or spectrum peak accessors to locate where to add the test.src/tests/class_tests/openms/source/LinearResamplerAlign_test.cpp (1)
63-73: Prefer stack objects over raw pointers in this test section.Line 63 to Line 73 use manual
new/deleteonly to exercise ctor/dtor. Use scoped stack allocation instead; it’s simpler and avoids pointer management noise.As per coding guidelines: "Avoid pointers; prefer references in C++".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/tests/class_tests/openms/source/LinearResamplerAlign_test.cpp` around lines 63 - 73, Replace the heap allocation and manual delete with a stack-allocated object: remove lr_ptr and lr_nullPointer, and in START_SECTION(LinearResamplerAlign()) construct a local LinearResamplerAlign lr; then assert the object exists by e.g. TEST_NOT_EQUAL(&lr, static_cast<LinearResamplerAlign*>(nullptr)) or other non-null pointer check if you need a pointer; remove the explicit delete in the destructor section since the stack object will be destroyed automatically. Ensure references to lr_ptr are updated to use lr (or &lr where a pointer is required).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@doc/doxygen/parameters/DefaultParamHandlerDocumenter.cpp`:
- Line 435: The inline comment beside DOCME2(BinnedSpectrumCompareFunctor,
(BinnedSharedPeakCount())); is incorrect: it refers to BaseModel but the
documented symbol is BinnedSpectrumCompareFunctor. Update the comment to refer
to the actual symbol—e.g., note that BinnedSpectrumCompareFunctor is the base
functor and parameters are taken from the subclass BinnedSharedPeakCount (or
state that BinnedSpectrumCompareFunctor documents parameters from
BinnedSharedPeakCount), so replace the mismatched "BaseModel" text with
"BinnedSpectrumCompareFunctor" (or rephrase to clarify the relationship between
BinnedSpectrumCompareFunctor and BinnedSharedPeakCount).
In `@src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h`:
- Around line 36-37: The Doxygen `@warning` block in LinearResamplerAlign.h is
malformed and unclear: replace the invalid "@param spacing_" usage with a proper
inline reference (e.g., "@p spacing_" or "spacing_") and rewrite the warning
text to be syntactically correct and clearer (for example: "@warning If the
minimal distance between two points is less than `@p` spacing_, using a sampling
rate below the instrument dead time can produce incorrectly distributed or
missing peaks."). Update the comment for the LinearResamplerAlign class/function
where spacing_ is documented to use this corrected `@warning` formatting and
wording.
- Around line 327-336: Add Doxygen documentation for the public method
rasterExperiment describing purpose, parameters (PeakMap& exp), behavior and
return, and explicitly state whether chromatograms are processed; if
chromatograms must be resampled, update rasterExperiment to iterate
exp.getChromatograms() and call the appropriate resampling routine, otherwise
document why chromatograms are intentionally excluded. Also fix the indentation
of the opening brace for rasterExperiment to use 4 spaces to match project
style. Ensure you reference rasterExperiment, raster(exp[i]) and
getChromatograms() in the comment so reviewers can see the intended handling.
---
Outside diff comments:
In `@src/pyOpenMS/bindings/bind_misc.cpp`:
- Around line 2646-2654: The LinearResamplerAlign binding needs to inherit
DefaultParamHandler, expose its raster overloads, and add copy semantics: modify
the nb::class_ declaration for OpenMS::LinearResamplerAlign to include
nb::base<OpenMS::DefaultParamHandler>(), add bindings for both raster methods
(e.g., raster(OpenMS::MSChromatogram&) and raster(OpenMS::MSExperiment&)) in
addition to the existing rasterExperiment, and add the copy constructor and
Python helpers by binding the copy ctor and methods __copy__ and __deepcopy__
(forwarding to the copy ctor) so getDefaults()/DefaultParamHandler methods and
proper copy behavior are available; keep
def_ProgressLogger<OpenMS::LinearResamplerAlign>(...) as-is.
---
Nitpick comments:
In `@src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h`:
- Around line 339-344: The doc comment "Spacing of the resampled data" is
attached to the wrong member; move that comment so it documents spacing_ (double
spacing_) rather than ppm_ (bool ppm_). In the class LinearResamplerAlign
(header OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h) adjust the member
declarations so spacing_ is immediately preceded by the "Spacing of the
resampled data" comment and leave ppm_ with an appropriate or no comment.
- Line 112: The two calls to verifySpacing_ use inconsistent lambda forms;
replace the explicit template lambda in the call that currently uses []<typename
PeakTypeIterator>(PeakTypeIterator x){ return x->getPos(); } with a generic
lambda using auto (i.e. [](auto x){ return x->getPos(); }) so both
verifySpacing_ invocations use the same simple generic-lambda style; update the
call site that references PeakTypeIterator/getPos to use the [](auto x){...}
form.
- Around line 386-406: The verifySpacing_ helper uses inconsistent brace
placement and an unsafe loop condition; update the function (verifySpacing_) to
place opening braces on their own lines per style, and replace while (it !=
end-1) with while (std::next(it) != end) (or equivalently while (it + 1 != end)
for random-access) to avoid iterator arithmetic on non-random-access iterators;
keep the initial guard (if (it == end || std::next(it) == end) return) and the
access(...) distance calculation unchanged, and ensure the OPENMS_LOG_WARN call
remains after the loop with its braces on separate lines as well.
In `@src/pyOpenMS/tests/unittests/test000.py`:
- Around line 1865-1866: Create a small behavioral round-trip for
LinearResamplerAlign.rasterExperiment: instantiate
pyopenms.LinearResamplerAlign(), build a tiny pyopenms.MSExperiment with one
spectrum containing a single peak (set m/z and intensity), assign it to
lr.rasterExperiment, then retrieve lr.rasterExperiment and assert the spectrum
count and the first spectrum's peak m/z/intensity match the original; reference
LinearResamplerAlign, rasterExperiment, MSExperiment and
getNrSpectra()/get_peaks()/or spectrum peak accessors to locate where to add the
test.
In `@src/tests/class_tests/openms/source/LinearResamplerAlign_test.cpp`:
- Around line 63-73: Replace the heap allocation and manual delete with a
stack-allocated object: remove lr_ptr and lr_nullPointer, and in
START_SECTION(LinearResamplerAlign()) construct a local LinearResamplerAlign lr;
then assert the object exists by e.g. TEST_NOT_EQUAL(&lr,
static_cast<LinearResamplerAlign*>(nullptr)) or other non-null pointer check if
you need a pointer; remove the explicit delete in the destructor section since
the stack object will be destroyed automatically. Ensure references to lr_ptr
are updated to use lr (or &lr where a pointer is required).
🪄 Autofix (Beta)
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
Run ID: 783b3f49-a918-43dc-a254-c4dd965947f5
📒 Files selected for processing (16)
AUTHORSCHANGELOGdoc/code_examples/Tutorial_SavitzkyGolayFilter.cppdoc/doxygen/parameters/DefaultParamHandlerDocumenter.cppsrc/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResampler.hsrc/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.hsrc/openms/include/OpenMS/PROCESSING/RESAMPLING/sources.cmakesrc/openms/source/PROCESSING/RESAMPLING/LinearResampler.cppsrc/openms/source/PROCESSING/RESAMPLING/sources.cmakesrc/openms_gui/source/VISUAL/APPLICATIONS/GUITOOLS/ImageCreator.cppsrc/pyOpenMS/bindings/bind_misc.cppsrc/pyOpenMS/tests/unittests/test000.pysrc/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/LinearResamplerAlign_test.cppsrc/tests/class_tests/openms/source/LinearResampler_test.cppsrc/topp/Resampler.cpp
💤 Files with no reviewable changes (7)
- src/openms/source/PROCESSING/RESAMPLING/sources.cmake
- src/openms/include/OpenMS/PROCESSING/RESAMPLING/sources.cmake
- src/tests/class_tests/openms/executables.cmake
- src/openms/source/PROCESSING/RESAMPLING/LinearResampler.cpp
- src/openms_gui/source/VISUAL/APPLICATIONS/GUITOOLS/ImageCreator.cpp
- src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResampler.h
- src/tests/class_tests/openms/source/LinearResampler_test.cpp
LinearResamplerAlign is a strict superset of LinearResampler (adds explicit raster alignment, ppm-spaced rasters, chromatogram support and a linear-interpolation mode). Delete the narrower LinearResampler class and redirect its callers (Tutorial_SavitzkyGolayFilter, ImageCreator, DefaultParamHandlerDocumenter, pyOpenMS binding) to LinearResamplerAlign. Also add a runtime warning (verifySpacing_) when the configured spacing is finer than the minimum distance between adjacent input points, which can produce spurious peaks below the detector dead time. Co-authored-by: Luis Jacob Keller <[email protected]> Co-authored-by: Alen Saric <[email protected]> Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
4a7865a to
f2a96b9
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/tests/class_tests/openms/source/LinearResamplerAlign_test.cpp (1)
59-65: Use snake_case here and simplify the null check.Line 60 (
lr_nullPointer) breaks snake_case and is unnecessary for the assertion; compare directly tonullptr.Proposed cleanup
-LinearResamplerAlign* lr_ptr = nullptr; -LinearResamplerAlign* lr_nullPointer = nullptr; +LinearResamplerAlign* lr_ptr = nullptr; START_SECTION(LinearResamplerAlign()) lr_ptr = new LinearResamplerAlign; - TEST_NOT_EQUAL(lr_ptr, lr_nullPointer); + TEST_NOT_EQUAL(lr_ptr, nullptr); END_SECTIONAs per coding guidelines, "Use snake_case for variable names in C++".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/tests/class_tests/openms/source/LinearResamplerAlign_test.cpp` around lines 59 - 65, The test creates an unnecessary camelCase variable lr_nullPointer and should use snake_case and a direct nullptr comparison: remove lr_nullPointer, keep (or rename) lr_ptr as a snake_case pointer variable, allocate it with new LinearResamplerAlign in the START_SECTION block, and replace TEST_NOT_EQUAL(lr_ptr, lr_nullPointer) with TEST_NOT_EQUAL(lr_ptr, nullptr) (references: LinearResamplerAlign, lr_ptr, START_SECTION, TEST_NOT_EQUAL).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/pyOpenMS/bindings/bind_misc.cpp`:
- Around line 2646-2655: The LinearResamplerAlign binding currently exposes only
nb::init<>(), so add the copy constructor and Python copy support: include
nb::init<const OpenMS::LinearResamplerAlign &>() for the copy ctor, then add
.def("__copy__", [](const OpenMS::LinearResamplerAlign &self){ return
OpenMS::LinearResamplerAlign(self); }) and .def("__deepcopy__", [](const
OpenMS::LinearResamplerAlign &self, nb::object /*memo*/){ return
OpenMS::LinearResamplerAlign(self); }) to the nb::class_ chain for
OpenMS::LinearResamplerAlign so it matches other pyOpenMS classes and preserves
copy/deepcopy behavior.
---
Nitpick comments:
In `@src/tests/class_tests/openms/source/LinearResamplerAlign_test.cpp`:
- Around line 59-65: The test creates an unnecessary camelCase variable
lr_nullPointer and should use snake_case and a direct nullptr comparison: remove
lr_nullPointer, keep (or rename) lr_ptr as a snake_case pointer variable,
allocate it with new LinearResamplerAlign in the START_SECTION block, and
replace TEST_NOT_EQUAL(lr_ptr, lr_nullPointer) with TEST_NOT_EQUAL(lr_ptr,
nullptr) (references: LinearResamplerAlign, lr_ptr, START_SECTION,
TEST_NOT_EQUAL).
🪄 Autofix (Beta)
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
Run ID: 9bb062db-952f-4929-845f-9f96405c1e85
📒 Files selected for processing (16)
AUTHORSCHANGELOGdoc/code_examples/Tutorial_SavitzkyGolayFilter.cppdoc/doxygen/parameters/DefaultParamHandlerDocumenter.cppsrc/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResampler.hsrc/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.hsrc/openms/include/OpenMS/PROCESSING/RESAMPLING/sources.cmakesrc/openms/source/PROCESSING/RESAMPLING/LinearResampler.cppsrc/openms/source/PROCESSING/RESAMPLING/sources.cmakesrc/openms_gui/source/VISUAL/APPLICATIONS/GUITOOLS/ImageCreator.cppsrc/pyOpenMS/bindings/bind_misc.cppsrc/pyOpenMS/tests/unittests/test000.pysrc/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/LinearResamplerAlign_test.cppsrc/tests/class_tests/openms/source/LinearResampler_test.cppsrc/topp/Resampler.cpp
💤 Files with no reviewable changes (8)
- doc/doxygen/parameters/DefaultParamHandlerDocumenter.cpp
- src/openms/include/OpenMS/PROCESSING/RESAMPLING/sources.cmake
- src/tests/class_tests/openms/executables.cmake
- src/openms/source/PROCESSING/RESAMPLING/sources.cmake
- src/openms/source/PROCESSING/RESAMPLING/LinearResampler.cpp
- src/openms_gui/source/VISUAL/APPLICATIONS/GUITOOLS/ImageCreator.cpp
- src/tests/class_tests/openms/source/LinearResampler_test.cpp
- src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResampler.h
✅ Files skipped from review due to trivial changes (5)
- AUTHORS
- src/topp/Resampler.cpp
- CHANGELOG
- doc/code_examples/Tutorial_SavitzkyGolayFilter.cpp
- src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h
🚧 Files skipped from review as they are similar to previous changes (1)
- src/pyOpenMS/tests/unittests/test000.py
| START_SECTION(( template <typename PeakType > void rasterExperiment(MSExperiment<PeakType>& exp))) | ||
| { | ||
| MSSpectrum spec; | ||
| spec.resize(5); | ||
| spec[0].setMZ(0); | ||
| spec[0].setIntensity(3.0f); | ||
| spec[1].setMZ(0.5); | ||
| spec[1].setIntensity(6.0f); | ||
| spec[2].setMZ(1.); | ||
| spec[2].setIntensity(8.0f); | ||
| spec[3].setMZ(1.6); | ||
| spec[3].setIntensity(2.0f); | ||
| spec[4].setMZ(1.8); | ||
| spec[4].setIntensity(1.0f); | ||
|
|
||
| PeakMap exp; | ||
| exp.addSpectrum(spec); | ||
| exp.addSpectrum(spec); | ||
|
|
||
| LinearResamplerAlign lr; | ||
| Param param; | ||
| param.setValue("spacing",0.5); | ||
| lr.setParameters(param); | ||
| lr.rasterExperiment(exp); | ||
|
|
||
|
|
||
| for (Size s=0; s<exp.size(); ++s) | ||
| { | ||
| double sum = 0.0; | ||
| for (Size i=0; i<exp[s].size(); ++i) | ||
| { | ||
| sum += exp[s][i].getIntensity(); | ||
| } | ||
| TEST_REAL_SIMILAR(sum, 20); | ||
| } |
There was a problem hiding this comment.
rasterExperiment assertions are too weak for this new coverage.
The section currently checks only summed intensity (Line 161). That can pass even when peak redistribution is wrong. Please add point-wise assertions (or explicit expected bins) so regressions in resampling shape are caught.
Suggested stronger assertions
lr.rasterExperiment(exp);
- for (Size s=0; s<exp.size(); ++s)
+ TEST_EQUAL(exp.size(), 2);
+ TEST_EQUAL(exp[0].size(), exp[1].size());
+
+ for (Size s = 0; s < exp.size(); ++s)
{
double sum = 0.0;
- for (Size i=0; i<exp[s].size(); ++i)
+ for (Size i = 0; i < exp[s].size(); ++i)
{
sum += exp[s][i].getIntensity();
}
TEST_REAL_SIMILAR(sum, 20);
}
+
+ for (Size i = 0; i < exp[0].size(); ++i)
+ {
+ TEST_REAL_SIMILAR(exp[0][i].getMZ(), exp[1][i].getMZ());
+ TEST_REAL_SIMILAR(exp[0][i].getIntensity(), exp[1][i].getIntensity());
+ }Based on learnings, "Write unit tests for new functionality and ensure existing tests pass before suggesting changes."
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| START_SECTION(( template <typename PeakType > void rasterExperiment(MSExperiment<PeakType>& exp))) | |
| { | |
| MSSpectrum spec; | |
| spec.resize(5); | |
| spec[0].setMZ(0); | |
| spec[0].setIntensity(3.0f); | |
| spec[1].setMZ(0.5); | |
| spec[1].setIntensity(6.0f); | |
| spec[2].setMZ(1.); | |
| spec[2].setIntensity(8.0f); | |
| spec[3].setMZ(1.6); | |
| spec[3].setIntensity(2.0f); | |
| spec[4].setMZ(1.8); | |
| spec[4].setIntensity(1.0f); | |
| PeakMap exp; | |
| exp.addSpectrum(spec); | |
| exp.addSpectrum(spec); | |
| LinearResamplerAlign lr; | |
| Param param; | |
| param.setValue("spacing",0.5); | |
| lr.setParameters(param); | |
| lr.rasterExperiment(exp); | |
| for (Size s=0; s<exp.size(); ++s) | |
| { | |
| double sum = 0.0; | |
| for (Size i=0; i<exp[s].size(); ++i) | |
| { | |
| sum += exp[s][i].getIntensity(); | |
| } | |
| TEST_REAL_SIMILAR(sum, 20); | |
| } | |
| START_SECTION(( template <typename PeakType > void rasterExperiment(MSExperiment<PeakType>& exp))) | |
| { | |
| MSSpectrum spec; | |
| spec.resize(5); | |
| spec[0].setMZ(0); | |
| spec[0].setIntensity(3.0f); | |
| spec[1].setMZ(0.5); | |
| spec[1].setIntensity(6.0f); | |
| spec[2].setMZ(1.); | |
| spec[2].setIntensity(8.0f); | |
| spec[3].setMZ(1.6); | |
| spec[3].setIntensity(2.0f); | |
| spec[4].setMZ(1.8); | |
| spec[4].setIntensity(1.0f); | |
| PeakMap exp; | |
| exp.addSpectrum(spec); | |
| exp.addSpectrum(spec); | |
| LinearResamplerAlign lr; | |
| Param param; | |
| param.setValue("spacing",0.5); | |
| lr.setParameters(param); | |
| lr.rasterExperiment(exp); | |
| TEST_EQUAL(exp.size(), 2); | |
| TEST_EQUAL(exp[0].size(), exp[1].size()); | |
| for (Size s = 0; s < exp.size(); ++s) | |
| { | |
| double sum = 0.0; | |
| for (Size i = 0; i < exp[s].size(); ++i) | |
| { | |
| sum += exp[s][i].getIntensity(); | |
| } | |
| TEST_REAL_SIMILAR(sum, 20); | |
| } | |
| for (Size i = 0; i < exp[0].size(); ++i) | |
| { | |
| TEST_REAL_SIMILAR(exp[0][i].getMZ(), exp[1][i].getMZ()); | |
| TEST_REAL_SIMILAR(exp[0][i].getIntensity(), exp[1][i].getIntensity()); | |
| } |
|
RasterExperiment was removed since it was only used in testing.. |
| // $Authors: Hannes Roest, Luis Jacob Keller, Alen Saric$ | ||
| // $Authors: Hannes Roest, Luis Jacob Keller, Alen Saric$ |
There was a problem hiding this comment.
I think you merged into your old local state... wait a second and give me permissions to commit on your branch and I will gix
There was a problem hiding this comment.
Fixed — force-pushed 9b4c16dbe4 which resets to the clean squash and cherry-picks only the compiling parts of your CodeRabbit-response commit (stack-alloc test, new pyOpenMS overloads). The duplicated class inheritance etc. was from git trying to merge your new commit against the pre-squash history.
There was a problem hiding this comment.
Actionable comments posted: 8
♻️ Duplicate comments (1)
src/pyOpenMS/bindings/bind_misc.cpp (1)
2664-2666:⚠️ Potential issue | 🟠 MajorAdd
rasterExperimentbinding or update Python API documentation.The C++ class has a
rasterExperiment(PeakMap& exp)method (with progress tracking), but onlyrasteroverloads are exposed in Python bindings. This breaks existing Python code callinglinearresampleralign.rasterExperiment(...). If intentionally replacing the method, ensure the change is documented and consider whether progress tracking is needed in the Python API.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/pyOpenMS/bindings/bind_misc.cpp` around lines 2664 - 2666, The Python bindings expose LinearResamplerAlign::raster overloads but omit LinearResamplerAlign::rasterExperiment(PeakMap&), breaking callers of linearresampleralign.rasterExperiment; restore the binding in src/pyOpenMS/bindings/bind_misc.cpp by adding a .def for "rasterExperiment" that forwards to self.rasterExperiment(exp) (use OpenMS::MSExperiment/PeakMap as the argument type used elsewhere) and ensure the binding signature supports progress reporting if desired (mirror any existing progress-tracking overloads or provide an optional callback/parameter consistent with other bindings), or if the method was intentionally replaced, update the Python API docs to state rasterExperiment was removed and map callers to the available raster overloads.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h`:
- Around line 164-167: The code calls verifySpacing_ twice on the same input
range, causing redundant full-range scans and duplicate warnings; remove the
duplicate invocations so each overload only calls verifySpacing_ once — update
both the m/z-intensity overload and the raster_interpolate() code paths to
eliminate the second verifySpacing_ call (keep a single verifySpacing_(raw_it,
raw_end, [](auto x){return x->getPos();}) per path).
- Around line 44-55: The class LinearResamplerAlign contains duplicate
base-specifiers (DefaultParamHandler, ProgressLogger) and two declarations of
the default constructor LinearResamplerAlign(), which makes the class invalid;
remove the duplicated inheritance list and the redundant constructor declaration
so there is a single inheritance clause and a single constructor definition for
LinearResamplerAlign (keeping the intended
DefaultParamHandler("LinearResamplerAlign") initializer in the one remaining
constructor).
- Around line 408-428: The comparison in verifySpacing_ is invalid when ppm_
mode is enabled because spacing_ is in ppm while min_dist is in absolute m/z
units; convert spacing_ to an absolute gap before comparing: inside
verifySpacing_ (use access, spacing_, ppm_, min_dist and the iterator it)
compute a local absolute spacing_abs = ppm_ ? (current_mz * spacing_ / 1e6)
where current_mz can be the m/z of the current iterator (or midpoint between it
and std::next(it)) and then compare spacing_abs < min_dist (and use spacing_abs
in the warning message), otherwise keep the existing absolute spacing_
comparison and message.
In `@src/pyOpenMS/bindings/bind_misc.cpp`:
- Around line 2660-2661: The Python bindings for LinearResamplerAlign are
calling the wrong C++ method and dropping results: update both lambdas to call
self.raster_interpolate(...) instead of self.raster(...), accept the output
parameter by reference (std::vector<...>& output) so the resampled peaks are
written into the caller-provided container, and return the (now-populated)
output vector to Python; apply this change for both Peak1D and Peak2D wrappers
referencing LinearResamplerAlign::raster_interpolate.
- Around line 2670-2717: The lambdas for OpenMS::LinearResamplerAlign::raster
currently mutate STL vectors (vector<double>, vector<OpenMS::Peak1D>,
vector<OpenMS::Peak2D> overloads and the eight-argument variants) which are
copied across the nanobind boundary, so change each lambda to call
self.raster(...) as today but then return the resampled output container(s)
(e.g., return the resampled vector or a tuple of resampled vectors) instead of
relying on in-place mutation; update the corresponding .def(...) bindings to
reflect the returned object(s) for the overloads referencing self.raster and the
argument names mz_resample/int_resample or resampled so Python callers receive
the modified containers.
In `@src/pyOpenMS/tests/unittests/test000.py`:
- Around line 1856-1869: Remove the duplicated function definition and repeated
lines for testLinearResamplerAlign: keep a single def
testLinearResamplerAlign(): block containing the docstring, one instantiation of
pyopenms.LinearResamplerAlign(), calling ff.getDefaults(), _testParam(p), and
the final assert checking .raster; delete the extra duplicate def and the
repeated statements so the test function is defined only once (references:
testLinearResamplerAlign, pyopenms.LinearResamplerAlign, ff.getDefaults,
_testParam, .raster).
In `@src/tests/class_tests/openms/source/LinearResamplerAlign_test.cpp`:
- Around line 14-24: Remove the duplicated `#include` directives: keep one each of
<OpenMS/KERNEL/MSSpectrum.h>, <OpenMS/KERNEL/Peak1D.h>, and
<OpenMS/test_config.h> and delete the extra occurrences (they are repeated in
the includes surrounding LinearResamplerAlign.h); update the top of
LinearResamplerAlign_test.cpp so each header is included only once to eliminate
merge-artifact duplicates.
- Around line 6-7: Remove the duplicated metadata author line by keeping a
single occurrence of the "$Authors: Hannes Roest, Luis Jacob Keller, Alen
Saric$" line in the file; locate the two identical "$Authors" lines (they appear
consecutively) and delete one so only one "$Authors" metadata line remains.
---
Duplicate comments:
In `@src/pyOpenMS/bindings/bind_misc.cpp`:
- Around line 2664-2666: The Python bindings expose LinearResamplerAlign::raster
overloads but omit LinearResamplerAlign::rasterExperiment(PeakMap&), breaking
callers of linearresampleralign.rasterExperiment; restore the binding in
src/pyOpenMS/bindings/bind_misc.cpp by adding a .def for "rasterExperiment" that
forwards to self.rasterExperiment(exp) (use OpenMS::MSExperiment/PeakMap as the
argument type used elsewhere) and ensure the binding signature supports progress
reporting if desired (mirror any existing progress-tracking overloads or provide
an optional callback/parameter consistent with other bindings), or if the method
was intentionally replaced, update the Python API docs to state rasterExperiment
was removed and map callers to the available raster overloads.
🪄 Autofix (Beta)
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
Run ID: df747143-6988-4004-a60b-f4bd70afe79c
📒 Files selected for processing (5)
doc/doxygen/parameters/DefaultParamHandlerDocumenter.cppsrc/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.hsrc/pyOpenMS/bindings/bind_misc.cppsrc/pyOpenMS/tests/unittests/test000.pysrc/tests/class_tests/openms/source/LinearResamplerAlign_test.cpp
| verifySpacing_(raw_it, raw_end, [](auto x){return x->getPos();}); | ||
|
|
||
| verifySpacing_(raw_it, raw_end, [](auto x){return x->getPos();}); | ||
|
|
There was a problem hiding this comment.
Call verifySpacing_ only once per overload.
Each of these paths invokes verifySpacing_ twice on the same input range. That doubles the full-range scan and prints the same warning twice for a single resampling call.
Proposed fix
- verifySpacing_(raw_it, raw_end, [](auto x){return x->getPos();});
verifySpacing_(raw_it, raw_end, [](auto x){return x->getPos();});Apply the same deletion in the m/z-intensity overload and in raster_interpolate().
Also applies to: 245-248, 316-319
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h`
around lines 164 - 167, The code calls verifySpacing_ twice on the same input
range, causing redundant full-range scans and duplicate warnings; remove the
duplicate invocations so each overload only calls verifySpacing_ once — update
both the m/z-intensity overload and the raster_interpolate() code paths to
eliminate the second verifySpacing_ call (keep a single verifySpacing_(raw_it,
raw_end, [](auto x){return x->getPos();}) per path).
| /// helper function to warn the user when the resampling rate is too high | ||
| template <typename PeakTypeIterator> | ||
| void verifySpacing_(PeakTypeIterator it, PeakTypeIterator end, auto access) | ||
| { | ||
| if (it == end || std::next(it) == end) return; | ||
| double min_dist = std::numeric_limits<double>::infinity(); | ||
| double current_dist{}; | ||
|
|
||
| while (it != end-1) | ||
| { | ||
| current_dist = (access(std::next(it)) - access(it)); | ||
| if (min_dist > current_dist) min_dist = current_dist; | ||
| ++it; | ||
| } | ||
|
|
||
| if (spacing_ < min_dist) | ||
| { | ||
| OPENMS_LOG_WARN << "you have chosen a resampling rate of: " << spacing_ <<\ | ||
| "\n this is smaller than the smallest Distance (" << min_dist << ") between Datapoints.\n\ | ||
| Since this approximates the dead time of the Detector this can result in fake peaks"; | ||
| } |
There was a problem hiding this comment.
Don’t compare ppm spacing to absolute point distances.
min_dist is computed in the container’s coordinate units, but spacing_ is a ppm value when ppm_ is enabled. In that mode this warning becomes misleading, because the comparison is no longer dimensionally valid.
Safer short-term fix
- if (spacing_ < min_dist)
+ if (!ppm_ && spacing_ < min_dist)If you want the warning in ppm mode as well, convert the configured ppm spacing to a local absolute gap before comparing.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h`
around lines 408 - 428, The comparison in verifySpacing_ is invalid when ppm_
mode is enabled because spacing_ is in ppm while min_dist is in absolute m/z
units; convert spacing_ to an absolute gap before comparing: inside
verifySpacing_ (use access, spacing_, ppm_, min_dist and the iterator it)
compute a local absolute spacing_abs = ppm_ ? (current_mz * spacing_ / 1e6)
where current_mz can be the m/z of the current iterator (or midpoint between it
and std::next(it)) and then compare spacing_abs < min_dist (and use spacing_abs
in the warning message), otherwise keep the existing absolute spacing_
comparison and message.
| .def("raster_interpolate", [](OpenMS::LinearResamplerAlign& self, std::vector<OpenMS::Peak1D> input, std::vector<OpenMS::Peak1D> output) { return self.raster(input.begin(), input.end(), output.begin(), output.end()); }, "input"_a, "output"_a, "Resamples the data a container (P1D) to the peak positions in another (P1D)") | ||
| .def("raster_interpolate", [](OpenMS::LinearResamplerAlign& self, std::vector<OpenMS::Peak2D> input, std::vector<OpenMS::Peak2D> output) { return self.raster(input.begin(), input.end(), output.begin(), output.end()); }, "input"_a, "output"_a, "Resamples the data a container (P2D) to the peak positions in another (P2D)") |
There was a problem hiding this comment.
raster_interpolate currently calls the wrong algorithm and drops the result.
These wrappers invoke self.raster(...) instead of self.raster_interpolate(...), so Python gets redistribution-based resampling rather than interpolation. They also return None after mutating a local output copy, so the computed peaks never reach the caller.
♻️ Proposed fix
- .def("raster_interpolate", [](OpenMS::LinearResamplerAlign& self, std::vector<OpenMS::Peak1D> input, std::vector<OpenMS::Peak1D> output) { return self.raster(input.begin(), input.end(), output.begin(), output.end()); }, "input"_a, "output"_a, "Resamples the data a container (P1D) to the peak positions in another (P1D)")
- .def("raster_interpolate", [](OpenMS::LinearResamplerAlign& self, std::vector<OpenMS::Peak2D> input, std::vector<OpenMS::Peak2D> output) { return self.raster(input.begin(), input.end(), output.begin(), output.end()); }, "input"_a, "output"_a, "Resamples the data a container (P2D) to the peak positions in another (P2D)")
+ .def("raster_interpolate", [](OpenMS::LinearResamplerAlign& self, std::vector<OpenMS::Peak1D> input, std::vector<OpenMS::Peak1D> output) {
+ self.raster_interpolate(input.begin(), input.end(), output.begin(), output.end());
+ return output;
+ }, "input"_a, "output"_a, "Interpolate intensities from one Peak1D container onto another")
+ .def("raster_interpolate", [](OpenMS::LinearResamplerAlign& self, std::vector<OpenMS::Peak2D> input, std::vector<OpenMS::Peak2D> output) {
+ self.raster_interpolate(input.begin(), input.end(), output.begin(), output.end());
+ return output;
+ }, "input"_a, "output"_a, "Interpolate intensities from one Peak2D container onto another")🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/pyOpenMS/bindings/bind_misc.cpp` around lines 2660 - 2661, The Python
bindings for LinearResamplerAlign are calling the wrong C++ method and dropping
results: update both lambdas to call self.raster_interpolate(...) instead of
self.raster(...), accept the output parameter by reference (std::vector<...>&
output) so the resampled peaks are written into the caller-provided container,
and return the (now-populated) output vector to Python; apply this change for
both Peak1D and Peak2D wrappers referencing
LinearResamplerAlign::raster_interpolate.
| // $Authors: Hannes Roest, Luis Jacob Keller, Alen Saric$ | ||
| // $Authors: Hannes Roest, Luis Jacob Keller, Alen Saric$ |
There was a problem hiding this comment.
Duplicate $Authors line.
The author metadata line is duplicated. Remove one instance.
🔧 Proposed fix
// $Maintainer: Hannes Roest $
// $Authors: Hannes Roest, Luis Jacob Keller, Alen Saric$
-// $Authors: Hannes Roest, Luis Jacob Keller, Alen Saric$
// --------------------------------------------------------------------------🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/tests/class_tests/openms/source/LinearResamplerAlign_test.cpp` around
lines 6 - 7, Remove the duplicated metadata author line by keeping a single
occurrence of the "$Authors: Hannes Roest, Luis Jacob Keller, Alen Saric$" line
in the file; locate the two identical "$Authors" lines (they appear
consecutively) and delete one so only one "$Authors" metadata line remains.
LinearResamplerAlign is a strict superset of LinearResampler (adds explicit raster alignment, ppm-spaced rasters, chromatogram support and a linear-interpolation mode). Delete the narrower LinearResampler class and redirect its callers (Tutorial_SavitzkyGolayFilter, ImageCreator, DefaultParamHandlerDocumenter, pyOpenMS binding) to LinearResamplerAlign. Also add a runtime warning (verifySpacing_) when the configured spacing is finer than the minimum distance between adjacent input points, which can produce spurious peaks below the detector dead time. Co-authored-by: Luis Jacob Keller <[email protected]> Co-authored-by: Alen Saric <[email protected]> Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
4f6d43c to
cef0aa6
Compare
LinearResamplerAlign is a strict superset of LinearResampler (adds explicit raster alignment, ppm-spaced rasters, chromatogram support and a linear-interpolation mode). Delete the narrower LinearResampler class and redirect its callers (Tutorial_SavitzkyGolayFilter, ImageCreator, DefaultParamHandlerDocumenter, pyOpenMS binding) to LinearResamplerAlign. Also add a runtime warning (verifySpacing_) when the configured spacing is finer than the minimum distance between adjacent input points, which can produce spurious peaks below the detector dead time. Co-authored-by: Luis Jacob Keller <[email protected]> Co-authored-by: Alen Saric <[email protected]> Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
cef0aa6 to
9b4c16d
Compare
|
Force-pushed Fixed (from the merge breakage)
Cherry-picked from
New review items addressed
Kept (disagreeing with one bit of feedback)
Verified locally
CI has the workflows in |
|
let's see if CI passes now. I will merge if it does. thanks! |
There was a problem hiding this comment.
♻️ Duplicate comments (3)
src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h (1)
395-416:⚠️ Potential issue | 🟠 MajorDimensionally invalid comparison when
ppm_mode is enabled.The comparison
spacing_ < min_diston line 410 compares apples to oranges whenppm_istrue:spacing_is in parts-per-million whilemin_distis computed in absolute m/z units (Th). This will produce misleading warnings or fail to warn when appropriate.As noted in a previous review, the safest short-term fix is to skip this check in ppm mode. If warnings in ppm mode are desired, convert the configured ppm spacing to an absolute value for comparison.
🔧 Proposed short-term fix
- if (spacing_ < min_dist) + if (!ppm_ && spacing_ < min_dist) { OPENMS_LOG_WARN << "Resampling spacing (" << spacing_ << ") is smaller than the smallest distance between data points (" << min_dist << "). This approximates the detector dead time and may produce spurious peaks.\n"; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h` around lines 395 - 416, The warning in verifySpacing_ compares spacing_ (ppm when ppm_ is true) to min_dist (absolute m/z), which is invalid; modify verifySpacing_ to skip the spacing_ < min_dist check when ppm_ is true (or alternatively convert spacing_ to absolute m/z before comparing), i.e., add a guard using the ppm_ flag so the OPENMS_LOG_WARN branch only runs when ppm_ is false (or compute absolute_spacing from spacing_ and current m/z and compare absolute_spacing < min_dist) while keeping the rest of the min_dist computation unchanged.src/pyOpenMS/bindings/bind_misc.cpp (1)
2646-2653:⚠️ Potential issue | 🟡 MinorRestore copy/deepcopy bindings for
LinearResamplerAlign.Line 2652 currently exposes only
nb::init<>(); copy constructor plus__copy__/__deepcopy__are missing for this class.♻️ Proposed fix
auto linearresampleralign_class = nb::class_<OpenMS::LinearResamplerAlign, OpenMS::DefaultParamHandler>(m, "LinearResamplerAlign", R"doc( Linear Resampling of raw data with alignment DefaultParamHandler ProgressLogger )doc") .def(nb::init<>()) + .def(nb::init<const OpenMS::LinearResamplerAlign &>()) + .def("__copy__", [](const OpenMS::LinearResamplerAlign& self) { return OpenMS::LinearResamplerAlign(self); }) + .def("__deepcopy__", [](const OpenMS::LinearResamplerAlign& self, nb::dict) { return OpenMS::LinearResamplerAlign(self); }, "memo"_a) .def("raster", [](OpenMS::LinearResamplerAlign& self, OpenMS::MSSpectrum& spectrum) { return self.raster(spectrum); }, "spectrum"_a, "Applies the resampling algorithm to an MSSpectrum")#!/bin/bash # Verify required copy bindings are present for LinearResamplerAlign rg -n -C3 'LinearResamplerAlign|nb::init<const OpenMS::LinearResamplerAlign|__copy__|__deepcopy__' src/pyOpenMS/bindings/bind_misc.cppAs per coding guidelines, "Class bindings must include default constructor
nb::init<>(), copy constructornb::init<const ClassName &>(),__copy__method, and__deepcopy__method with memo parameter".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/pyOpenMS/bindings/bind_misc.cpp` around lines 2646 - 2653, The LinearResamplerAlign binding only exposes nb::init<> but must also provide copy construction and Python copy semantics; update the linearresampleralign_class binding for OpenMS::LinearResamplerAlign to add nb::init<const OpenMS::LinearResamplerAlign &>() and define "__copy__" and "__deepcopy__" methods that return a copy (use a lambda that constructs OpenMS::LinearResamplerAlign(self) for __copy__ and __deepcopy__(self, memo) respectively), keeping the existing "raster" def intact.src/tests/class_tests/openms/source/LinearResamplerAlign_test.cpp (1)
155-163:⚠️ Potential issue | 🟠 MajorStrengthen
rasterExperimentvalidation beyond total-intensity conservation.At Line 155-Line 163, the test only checks summed intensity (
20) per spectrum. That can still pass with incorrect peak redistribution. Please assert expected resampled bins (m/z grid + per-bin intensities), especially since this section is new API-level coverage.Based on learnings, "Write unit tests for new functionality and ensure existing tests pass before suggesting changes."Suggested assertion upgrade
- for (Size s=0; s<exp.size(); ++s) + TEST_EQUAL(exp.size(), 2); + for (Size s = 0; s < exp.size(); ++s) { - double sum = 0.0; - for (Size i=0; i<exp[s].size(); ++i) - { - sum += exp[s][i].getIntensity(); - } - TEST_REAL_SIMILAR(sum, 20); + TEST_EQUAL(exp[s].size(), 5); + TEST_REAL_SIMILAR(exp[s][0].getMZ(), 0.0); + TEST_REAL_SIMILAR(exp[s][1].getMZ(), 0.5); + TEST_REAL_SIMILAR(exp[s][2].getMZ(), 1.0); + TEST_REAL_SIMILAR(exp[s][3].getMZ(), 1.5); + TEST_REAL_SIMILAR(exp[s][4].getMZ(), 2.0); + + TEST_REAL_SIMILAR(exp[s][0].getIntensity(), 3.0); + TEST_REAL_SIMILAR(exp[s][1].getIntensity(), 6.0); + TEST_REAL_SIMILAR(exp[s][2].getIntensity(), 8.0); + TEST_REAL_SIMILAR(exp[s][3].getIntensity(), 2.0); + TEST_REAL_SIMILAR(exp[s][4].getIntensity(), 1.0); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/tests/class_tests/openms/source/LinearResamplerAlign_test.cpp` around lines 155 - 163, The test currently only asserts total intensity per spectrum (loop over exp in LinearResamplerAlign_test.cpp), which can mask incorrect peak redistribution; update the test to validate the resampled m/z grid and per-bin intensities explicitly by asserting expected spectrum sizes (exp[s].size()), each bin's m/z (exp[s][i].getMZ()) and each bin's intensity (exp[s][i].getIntensity()) against the known expected vectors for the rasterExperiment case; target the loop that iterates over exp and add checks for exact bin positions and per-bin values (or approximate equality with TEST_REAL_SIMILAR) so the resampler behavior is fully specified.
🧹 Nitpick comments (1)
src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h (1)
304-305: Minor style inconsistency: useautofor lambda parameter.Other
verifySpacing_calls useautoin the lambda parameter (e.g., line 113, 156, 235), but this one explicitly specifiesPeakTypeIterator. Consider usingautofor consistency.♻️ Suggested fix
- verifySpacing_(raw_it, raw_end, [](PeakTypeIterator x){return x->getPos();}); + verifySpacing_(raw_it, raw_end, [](auto x){return x->getPos();});🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h` around lines 304 - 305, The call to verifySpacing_(raw_it, raw_end, [](PeakTypeIterator x){return x->getPos();}); uses an explicit PeakTypeIterator lambda parameter which is inconsistent with other calls; change the lambda parameter to auto (i.e., [](auto x){ return x->getPos(); }) so verifySpacing_, the lambda, raw_it and raw_end use the same style as the other calls for consistency.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h`:
- Around line 395-416: The warning in verifySpacing_ compares spacing_ (ppm when
ppm_ is true) to min_dist (absolute m/z), which is invalid; modify
verifySpacing_ to skip the spacing_ < min_dist check when ppm_ is true (or
alternatively convert spacing_ to absolute m/z before comparing), i.e., add a
guard using the ppm_ flag so the OPENMS_LOG_WARN branch only runs when ppm_ is
false (or compute absolute_spacing from spacing_ and current m/z and compare
absolute_spacing < min_dist) while keeping the rest of the min_dist computation
unchanged.
In `@src/pyOpenMS/bindings/bind_misc.cpp`:
- Around line 2646-2653: The LinearResamplerAlign binding only exposes
nb::init<> but must also provide copy construction and Python copy semantics;
update the linearresampleralign_class binding for OpenMS::LinearResamplerAlign
to add nb::init<const OpenMS::LinearResamplerAlign &>() and define "__copy__"
and "__deepcopy__" methods that return a copy (use a lambda that constructs
OpenMS::LinearResamplerAlign(self) for __copy__ and __deepcopy__(self, memo)
respectively), keeping the existing "raster" def intact.
In `@src/tests/class_tests/openms/source/LinearResamplerAlign_test.cpp`:
- Around line 155-163: The test currently only asserts total intensity per
spectrum (loop over exp in LinearResamplerAlign_test.cpp), which can mask
incorrect peak redistribution; update the test to validate the resampled m/z
grid and per-bin intensities explicitly by asserting expected spectrum sizes
(exp[s].size()), each bin's m/z (exp[s][i].getMZ()) and each bin's intensity
(exp[s][i].getIntensity()) against the known expected vectors for the
rasterExperiment case; target the loop that iterates over exp and add checks for
exact bin positions and per-bin values (or approximate equality with
TEST_REAL_SIMILAR) so the resampler behavior is fully specified.
---
Nitpick comments:
In `@src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.h`:
- Around line 304-305: The call to verifySpacing_(raw_it, raw_end,
[](PeakTypeIterator x){return x->getPos();}); uses an explicit PeakTypeIterator
lambda parameter which is inconsistent with other calls; change the lambda
parameter to auto (i.e., [](auto x){ return x->getPos(); }) so verifySpacing_,
the lambda, raw_it and raw_end use the same style as the other calls for
consistency.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9512d468-3c98-4271-9607-621c5d056128
📒 Files selected for processing (16)
AUTHORSCHANGELOGdoc/code_examples/Tutorial_SavitzkyGolayFilter.cppdoc/doxygen/parameters/DefaultParamHandlerDocumenter.cppsrc/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResampler.hsrc/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResamplerAlign.hsrc/openms/include/OpenMS/PROCESSING/RESAMPLING/sources.cmakesrc/openms/source/PROCESSING/RESAMPLING/LinearResampler.cppsrc/openms/source/PROCESSING/RESAMPLING/sources.cmakesrc/openms_gui/source/VISUAL/APPLICATIONS/GUITOOLS/ImageCreator.cppsrc/pyOpenMS/bindings/bind_misc.cppsrc/pyOpenMS/tests/unittests/test000.pysrc/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/LinearResamplerAlign_test.cppsrc/tests/class_tests/openms/source/LinearResampler_test.cppsrc/topp/Resampler.cpp
💤 Files with no reviewable changes (8)
- src/tests/class_tests/openms/executables.cmake
- src/openms_gui/source/VISUAL/APPLICATIONS/GUITOOLS/ImageCreator.cpp
- doc/doxygen/parameters/DefaultParamHandlerDocumenter.cpp
- src/openms/source/PROCESSING/RESAMPLING/sources.cmake
- src/openms/include/OpenMS/PROCESSING/RESAMPLING/sources.cmake
- src/openms/source/PROCESSING/RESAMPLING/LinearResampler.cpp
- src/tests/class_tests/openms/source/LinearResampler_test.cpp
- src/openms/include/OpenMS/PROCESSING/RESAMPLING/LinearResampler.h
✅ Files skipped from review due to trivial changes (4)
- AUTHORS
- src/topp/Resampler.cpp
- doc/code_examples/Tutorial_SavitzkyGolayFilter.cpp
- CHANGELOG
Description
We have found the base class of LinearResaplerAlign, LinearResampler to be obsolete. We have deleted the Class and merged the tests and funcs. Additionally we have built a warn message into the Resampler, reminding the user that too high a sampling rate may result in false Peaks to be created. This is a result of the resampler redistributing peaks into the direct neighbours on the resampled spectrum. This creates Areas of 0 intensity if more than three output points are enclosed by two input Points
(if sampling rate is smaller than the smallest gap in the spectrum - presumably the dead time of the detector)
Checklist
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf you click in the column that lists the failed tests you will get detailed error messages.
Advanced commands (admins / reviewer only)
Click to expand
/reformat(experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.rebuild jenkinswill retrigger Jenkins-based CI buildsSummary by CodeRabbit