Repository navigation
cleanup(scoring): remove deprecated C-array overloads (#9252) - #9255
timosachsenberg merged 1 commit into
Conversation
Removes the deprecated pointer-based overloads of NormalizedManhattanDist, RootMeanSquareDeviation, SpectralAngle, normalize_sum, and calcxcorr_legacy_mquest_ from OpenSwath::Scoring. Formula docstrings are preserved on the surviving std::vector& overloads. The legacy mquest equivalence/consistency tests (which only validated the removed function against itself) are deleted, and the remaining deprecated test call sites are migrated to the modern API. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
📝 WalkthroughWalkthroughThis PR removes deprecated C-style raw pointer overloads from the OpenSwath Scoring module ( Changes
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📋 Issue PlannerLet us write the prompt for your AI agent so you can ship faster (with fewer bugs). View plan for ticket: ✨ 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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/openswathalgo/source/OPENSWATHALGO/ALGO/Scoring.cpp (1)
119-145:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winGuard
lagbefore the cross-correlation loop.
lag == 0makesdelay += lagan infinite loop and also divides by zero in thereserveexpression. Please add anOPENSWATH_PRECONDITION(lag > 0, ...)here; if you want the reservation to stay accurate forlag > 1, cast the numerator todoublebeforeceil.🔧 Proposed fix
OPENSWATH_PRECONDITION(data1.size() == data2.size(), "Both data vectors need to have the same length"); + OPENSWATH_PRECONDITION(lag > 0, "lag must be positive"); XCorrArrayType result; - result.data.reserve( (size_t)std::ceil((2*maxdelay + 1) / lag)); + result.data.reserve(static_cast<size_t>(std::ceil((2.0 * maxdelay + 1) / lag)));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openswathalgo/source/OPENSWATHALGO/ALGO/Scoring.cpp` around lines 119 - 145, In calculateCrossCorrelation, guard against a non-positive lag by adding OPENSWATH_PRECONDITION(lag > 0, "lag must be > 0") before the loop to prevent an infinite loop and divide-by-zero; also fix the reserve calculation by casting the numerator to double (e.g., std::ceil((2.0 * maxdelay + 1.0) / lag)) so the reservation is correct for lag > 1.src/openswathalgo/include/OpenMS/OPENSWATHALGO/ALGO/Scoring.h (1)
63-103:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winFix the migrated formulas before the docs go public.
The Manhattan-distance doc still shows a square root, which doesn't match the implementation, and the spectral-angle equation still has a stray parenthesis. That will generate misleading API docs for the surviving overloads.
♻️ Proposed doc cleanup
- d = \sqrt{\frac{1}{N} \sum_{i=0}^N |\frac{x_i}{\mu_x} - \frac{y_i}{\mu_y}|) } + d = \frac{1}{N} \sum_{i=0}^{N-1} \left|\frac{x_i}{\mu_x} - \frac{y_i}{\mu_y}\right| - \theta = acos \left( \frac{\sum_{i=0}^N (x_i * y_i))}{\sqrt{\sum_{i=0}^N (x_i * x_i) \sum_{i=0}^N (y_i * y_i)} } \right) + \theta = \arccos \left( \frac{\sum_{i=0}^{N-1} x_i y_i}{\sqrt{\sum_{i=0}^{N-1} x_i^2 \sum_{i=0}^{N-1} y_i^2}} \right)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openswathalgo/include/OpenMS/OPENSWATHALGO/ALGO/Scoring.h` around lines 63 - 103, The docs contain incorrect LaTeX for NormalizedManhattanDist (shows an unnecessary square root) and a mismatched parenthesis in SpectralAngle; update the comment for NormalizedManhattanDist to show the mean absolute difference without sqrt (d = (1/N) sum |x_i/μ_x - y_i/μ_y|) and fix the SpectralAngle formula to remove the stray parenthesis and ensure the fraction is written correctly (acos( (sum x_i*y_i) / sqrt((sum x_i^2)*(sum y_i^2)) ) ), making sure these docstrings for NormalizedManhattanDist and SpectralAngle exactly match the implemented behavior and compile as valid Doxygen/LaTeX.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/openswathalgo/include/OpenMS/OPENSWATHALGO/ALGO/Scoring.h`:
- Around line 63-103: The docs contain incorrect LaTeX for
NormalizedManhattanDist (shows an unnecessary square root) and a mismatched
parenthesis in SpectralAngle; update the comment for NormalizedManhattanDist to
show the mean absolute difference without sqrt (d = (1/N) sum |x_i/μ_x -
y_i/μ_y|) and fix the SpectralAngle formula to remove the stray parenthesis and
ensure the fraction is written correctly (acos( (sum x_i*y_i) / sqrt((sum
x_i^2)*(sum y_i^2)) ) ), making sure these docstrings for
NormalizedManhattanDist and SpectralAngle exactly match the implemented behavior
and compile as valid Doxygen/LaTeX.
In `@src/openswathalgo/source/OPENSWATHALGO/ALGO/Scoring.cpp`:
- Around line 119-145: In calculateCrossCorrelation, guard against a
non-positive lag by adding OPENSWATH_PRECONDITION(lag > 0, "lag must be > 0")
before the loop to prevent an infinite loop and divide-by-zero; also fix the
reserve calculation by casting the numerator to double (e.g., std::ceil((2.0 *
maxdelay + 1.0) / lag)) so the reservation is correct for lag > 1.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1e384906-a9b2-47a0-946c-c80449eb2562
📒 Files selected for processing (4)
src/openms/source/ANALYSIS/OPENSWATH/ConfidenceScoring.cppsrc/openswathalgo/include/OpenMS/OPENSWATHALGO/ALGO/Scoring.hsrc/openswathalgo/source/OPENSWATHALGO/ALGO/Scoring.cppsrc/tests/class_tests/openswathalgo/Scoring_test.cpp
|
@CodeRabbit looks like a cwiseAbs was removed |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 9694
The only // REMOVED (deprecated array overload)
double NormalizedManhattanDist(double x[], double y[], int n)
{
...
return (vx - vy).cwiseAbs().sum() / n; // ← this cwiseAbs is gone
}The surviving vector-based overload // SURVIVES (vector overload) — cwiseAbs still present
double NormalizedManhattanDist(std::vector<double>& x, std::vector<double>& y)
{
...
normalize_sum(x);
normalize_sum(y);
Eigen::Map<Eigen::VectorXd> vx(x.data(), x.size());
Eigen::Map<Eigen::VectorXd> vy(y.data(), y.size());
return (vx - vy).cwiseAbs().sum() / x.size(); // ← cwiseAbs still here
}So there's no correctness regression — |
Summary
OpenSwath::Scoringoverloads (NormalizedManhattanDist,RootMeanSquareDeviation,SpectralAngle,normalize_sum) andcalcxcorr_legacy_mquest_, which were the source of the 15 deprecation warnings reported in deprecation warnings in our own tests #9252.std::vector&overloads, as @singjc requested in the issue thread.Scoring_test.cppand the two inConfidenceScoring.cppto the vector overloads.test_MRMFeatureScoring_calcxcorr_legacy_mquest_astest_MRMFeatureScoring_normalizedCrossCorrelation_full_range(per @jcharkow's suggestion to "rename to test the new function") — same reference values, full-range maxdelay coverage preserved.test_calcxcorr_legacy_equivalence,test_legacy_vs_normalized_consistency, and the unusedcalcxcorr_legacy_refhelper, which only validated the legacy function against itself or against the modern API and have no purpose once the legacy function is gone. Edge-case tests for zeros / constant-value inputs are migrated tonormalizedCrossCorrelation.Net change: +23 / −296 lines.
Closes #9252.
Test plan
cmake --build OpenMS-build --target Scoring_testis clean of-Wdeprecated-declarationswarnings from these symbols.Scoring_testpasses (all sections including the renamed full-range test).ctest -R "Scoring|ConfidenceScoring|MRMScoring|MRMFeatureFinderScoring"— 20/20 pass.🤖 Generated with Claude Code
Summary by CodeRabbit