Repository navigation
[FIX][pyOpenMS] Give keyword arguments the defaults their C++ signatures declare - #10137
Conversation
…res declare
Four bindings declared a parameter with no default after parameters that had
one. nanobind accepts that, but the resulting signature cannot be expressed in
Python, so nanobind.stubgen emitted stubs that are not valid Python:
_pyopenms_datastructures.pyi:782: non-default argument follows default argument
_pyopenms_misc.pyi:1000: non-default argument follows default argument
Each of the four arguments has a default in the C++ signature that the binding
simply did not carry over, so they become optional with those values:
- MultipleTesting.lfdr transf -> LfdrTransform.Probit
- IDMapper.annotate spectra -> MSExperiment() (FeatureMap overload)
- IDMapper.annotate spectra -> MSExperiment() (ConsensusMap overload)
- SwathFile.loadMzML plugin_consumer -> None (C++: nullptr)
BREAKING: while checking lfdr against MultipleTesting.h, two of its other
defaults turned out to be wrong as well. The binding declared gridsize = 100
and cut = 0.05; the C++ signature and its documentation use 512 and 3.0. Python
callers who omitted those arguments therefore got different results than C++
callers. They now match, which changes lfdr() output for such calls.
MultipleTesting's nested Pi0Method and LfdrTransform enums move ahead of the
method chain. nanobind converts default values to Python objects while the
binding is being created, so LfdrTransform::Probit has to be a registered type
by the time lfdr() is bound; registering the enums afterwards, as before, would
raise during module import.
Verified on Linux x86_64 / CPython 3.11:
- a scan of all 15 binding files reports no remaining ordering violations;
- all 18 generated .pyi files parse (previously 2 did not);
- lfdr() called with only p_values and pi0 returns exactly what the explicit
(Probit, 1.5, 1e-8, 512, 3.0) call returns, and both enums are still reachable
as MultipleTesting.LfdrTransform / MultipleTesting.Pi0Method;
- both IDMapper.annotate overloads work without the spectra argument;
- the pyOpenMS suite is unchanged: 5957 passed, 94 skipped, 10 xfailed,
7 xpassed, 0 failed.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dtk9KoddQxGPNyZkCPDKnT
|
CI note: The This PR only touches pyOpenMS binding sources and the CHANGELOG, and (The A re-run currently returns Generated by Claude Code |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughPyOpenMS bindings now match C++ defaults for ChangesPyOpenMS default alignment
Suggested reviewers: Priority: ➖ Normal Change: Bug fix Merge Risk: ⚪ Minimal · up to The updated Python defaults match the C++ APIs and introduce no remaining merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 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. A rabbit checks the bindings bright, Comment |
Description
Four bindings declared a parameter with no default after parameters that had one. nanobind accepts that, but the resulting signature cannot be expressed in Python, so
nanobind.stubgenemitted stubs that are not valid Python:Each of the four arguments already has a default in the C++ signature that the binding simply did not carry over, so they become optional with those values:
MultipleTesting.lfdrtransfLfdrTransform::ProbitIDMapper.annotate(FeatureMap overload)spectraPeakMap()IDMapper.annotate(ConsensusMap overload)spectraPeakMap()SwathFile.loadMzMLplugin_consumernullptr→NoneWhile checking
lfdragainstMultipleTesting.h, two of its other defaults turned out to be wrong as well. The binding declaredgridsize = 100andcut = 0.05; the C++ signature and its Doxygen documentation use512and3.0. Python callers who omitted those arguments therefore silently got different results than C++ callers. They now match, which changeslfdr()output for such calls.Note on the enum move
MultipleTesting's nestedPi0MethodandLfdrTransformenums move ahead of the method chain. nanobind converts default values to Python objects while the binding is being created, soLfdrTransform::Probithas to be a registered type by the timelfdr()is bound — registering the enums afterwards, as before, would raise during module import. Both remain reachable at the same names (MultipleTesting.LfdrTransform,MultipleTesting.Pi0Method).Verification
Linux x86_64 / CPython 3.11, full OpenMS + pyOpenMS build:
ast.parseonly reports the first error per file, which is why the stubs only surfaced 2)..pyifiles parse; previously 2 did not.lfdr(p_values, pi0)returns exactly what the explicit(…, Probit, 1.5, 1e-8, 512, 3.0)call returns.IDMapper.annotateoverloads work without thespectraargument.Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01Dtk9KoddQxGPNyZkCPDKnT
Generated by Claude Code
Summary by CodeRabbit
Bug Fixes
IDMapper.annotateandSwathFile.loadMzML.Breaking Changes
MultipleTesting.lfdrdefaults forgridsizeandcut, which may change results when these arguments are omitted.