Repository navigation
[TEST][pyOpenMS] Output params (§2): pin get_peaks / get2DPeakData* return-value wrapping (#9460) - #9608
Conversation
…eturn-value wrapping (#9460) Close the §2 (pyOpenMS nanobind rewrite) [AUTO] output-parameter gap (L94). The mutable-ref output params were wrapped to RETURN their results; test_output_parameters.py already covered ~50 such methods but not the numpy peak-data getters the issue names explicitly. Tests only. - TestMSSpectrumGetPeaks: MSSpectrum.get_peaks() returns the (mz, intensity) arrays (float64 / float32), with correct values and an empty-spectrum case. - TestMSExperimentGet2DPeakData: MSExperiment.get2DPeakData / get2DPeakDataLong / get2DPeakDataIM return the (rt, mz, intensity[, ion_mobility]) arrays the C++ fills by reference -- non-empty for an in-range query, get2DPeakDataLong keeps rt/mz at float64, get2DPeakDataIM returns the 4-tuple. numpy is importorskip-optional. Verified with the built nanobind bindings (5 passed). Co-Authored-By: Claude Opus 4.8 <[email protected]>
📝 WalkthroughWalkthroughAdds 104 lines of regression tests to ChangesOutput parameter binding regression tests
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. ✨ Finishing Touches📝 Generate docstrings
🧪 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/pyOpenMS/tests/unittests/test_output_parameters.py (1)
745-755:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winStrengthen IM in-range assertions to prevent false positives.
This test currently passes even if
get2DPeakDataIM(...)returns four empty arrays for an in-range query. Add a non-empty expectation (and ideally exact expected count) so it actually guards the output-parameter return contract.Suggested patch
def test_get2DPeakDataIM_returns_quadruple(self): pytest.importorskip("numpy") exp = self._make_exp() result = exp.get2DPeakDataIM(50.0, 250.0, 100.0, 300.0, 1) assert isinstance(result, tuple), f"Expected tuple, got {type(result)}" assert len(result) == 4 # rt, mz, intensity, ion_mobility rt, mz, intensity, ion_mobility = result # the four parallel arrays are all populated to the same length (output not dropped) assert len(rt) == len(mz) == len(intensity) == len(ion_mobility) + assert len(rt) == 4🤖 Prompt for 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. In `@src/pyOpenMS/tests/unittests/test_output_parameters.py` around lines 745 - 755, The test for the get2DPeakDataIM method does not verify that the returned arrays are actually populated with data. Currently it only checks that all four arrays (rt, mz, intensity, ion_mobility) have the same length, which could pass even if all arrays are empty. Add an assertion to ensure that the returned arrays are non-empty (len(rt) > 0) and if possible, verify the exact expected count of elements based on the query parameters passed to get2DPeakDataIM (50.0, 250.0, 100.0, 300.0, 1) to properly guard the output-parameter return contract.
🤖 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.
Outside diff comments:
In `@src/pyOpenMS/tests/unittests/test_output_parameters.py`:
- Around line 745-755: The test for the get2DPeakDataIM method does not verify
that the returned arrays are actually populated with data. Currently it only
checks that all four arrays (rt, mz, intensity, ion_mobility) have the same
length, which could pass even if all arrays are empty. Add an assertion to
ensure that the returned arrays are non-empty (len(rt) > 0) and if possible,
verify the exact expected count of elements based on the query parameters passed
to get2DPeakDataIM (50.0, 250.0, 100.0, 300.0, 1) to properly guard the
output-parameter return contract.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7bc1d1ba-dca0-460a-b996-3196d5f96b07
📒 Files selected for processing (1)
src/pyOpenMS/tests/unittests/test_output_parameters.py
|
Adversarial review result: no blocking issue found in this pass. Required source cleanup before merge: the added Python test docstrings include tracker references. Please remove those references from source comments/docstrings and keep the text focused on the output-parameter wrapping contract. I did not run the tests locally. |
|
@copilot Required source cleanup before merge: the added Python test docstrings include tracker references. Please remove those references from source comments/docstrings and keep the text focused on the output-parameter wrapping contract. I did not run the tests locally. |
Co-authored-by: timosachsenberg <[email protected]>
Addressed in commit |
Context
Closes the §2 (pyOpenMS nanobind rewrite)
[AUTO]output-parameter gap (L94) of the OpenMS 3.6.0 pre-release testing plan (#9460). Tests only.The nanobind rewrite re-wrapped the ~50 mutable-ref output params to return their results.
test_output_parameters.pyalready covers most of them, but not the numpy peak-data getters the issue names explicitly — this adds them.Changes (in
test_output_parameters.py)TestMSSpectrumGetPeaks—MSSpectrum.get_peaks()returns the(mz, intensity)arrays (float64 / float32) with correct values; plus an empty-spectrum case.TestMSExperimentGet2DPeakData—MSExperiment.get2DPeakData/get2DPeakDataLong/get2DPeakDataIMreturn the(rt, mz, intensity[, ion_mobility])arrays the C++ fills by reference: non-empty for an in-range query,get2DPeakDataLongkeeps rt/mz at float64,get2DPeakDataIMreturns the 4-tuple.numpyisimportorskip-optional.Test plan
→ 5 passed; no regressions in the rest of
test_output_parameters.py.Part of #9460 (§2).
🤖 Generated with Claude Code
Summary by CodeRabbit