Repository navigation
Fix wrap ignore jawn - #8119
Fix wrap ignore jawn#8119
Conversation
… to work with new cython and autowrap
## Walkthrough
The changes update type annotations and usage of peptide identification containers throughout the codebase, replacing Python lists with the more specific `_PeptideIdentificationList` type. Annotation comments for class declarations in Cython `.pxd` files are standardized. Test code is updated to use the new container type and associated methods. Minor comment additions and syntax cleanups are also included.
## Changes
| File(s) | Change Summary |
|------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|
| src/pyOpenMS/pxds/ConsensusMap.pxd | Removed `# wrap-ignore` from `getUnassignedPeptideIdentifications()` method declaration. |
| src/pyOpenMS/pxds/FeatureGroupingAlgorithm.pxd,<br>src/pyOpenMS/pxds/SpectrumAccessTransforming.pxd | Added `# wrap-ignore`, `# ABSTRACT class`, and `# no-pxd-import` annotations to class declarations; updated comments. |
| src/pyOpenMS/pxds/StringDataArray.pxd | Added comment noting `resize(size_t n)` method implemented in `.pyx` file; no signature changes. |
| src/pyOpenMS/pyopenms/_dataframes.py | Replaced all `list[PeptideIdentification]` with `_PeptideIdentificationList`; updated function signatures and list operations accordingly. |
| src/pyOpenMS/tests/unittests/test000.py | Updated tests to use `PeptideIdentificationList` and related methods instead of Python lists; adjusted assertions.|
| src/pyOpenMS/tests/unittests/test_FileIO.py | Replaced Python lists with `PeptideIdentificationList` for peptide identifications; updated size checks and removed redundant semicolons. |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant User
participant pyopenms._dataframes
participant _PeptideIdentificationList
User->>pyopenms._dataframes: Call peptide_identifications_to_df(peps)
pyopenms._dataframes->>_PeptideIdentificationList: Iterate, access, push_back, size, etc.
pyopenms._dataframes-->>User: Return DataFrame
User->>pyopenms._dataframes: Call update_scores_from_df(peps, df, main_score_name)
pyopenms._dataframes->>_PeptideIdentificationList: Update scores using push_back, size, etc.
pyopenms._dataframes-->>User: (operation complete)Poem
Learnt from: FreezB11 Learnt from: FreezB11 |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/pyOpenMS/pxds/ConsensusMap.pxd(1 hunks)src/pyOpenMS/pxds/FeatureGroupingAlgorithm.pxd(1 hunks)src/pyOpenMS/pxds/SpectrumAccessTransforming.pxd(1 hunks)src/pyOpenMS/pyopenms/_dataframes.py(9 hunks)src/pyOpenMS/tests/unittests/test000.py(8 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: FreezB11
PR: OpenMS/OpenMS#7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:4-4
Timestamp: 2025-06-16T15:48:09.667Z
Learning: In OpenMS .pxd files, the established pattern for extern from statements is to include angle brackets inside the string literal, like `cdef extern from "<OpenMS/PATH/TO/FILE.h>" namespace "OpenMS":`. This is consistent across all existing quantitation method .pxd files and other .pxd files in the OpenMS codebase.
Learnt from: FreezB11
PR: OpenMS/OpenMS#7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:1-3
Timestamp: 2025-06-16T15:49:26.504Z
Learning: In OpenMS Python bindings (.pxd files), derived quantitation method classes like TMTThirtyTwoPlexQuantitationMethod only need to declare their constructors. All other public methods (getName, getChannelInformation, getNumberOfChannels, getIsotopeCorrectionMatrix, getReferenceChannel) are inherited from the base IsobaricQuantitationMethod class and don't need to be redeclared explicitly.
src/pyOpenMS/pxds/ConsensusMap.pxd (2)
Learnt from: FreezB11
PR: OpenMS/OpenMS#7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:1-3
Timestamp: 2025-06-16T15:49:26.504Z
Learning: In OpenMS Python bindings (.pxd files), derived quantitation method classes like TMTThirtyTwoPlexQuantitationMethod only need to declare their constructors. All other public methods (getName, getChannelInformation, getNumberOfChannels, getIsotopeCorrectionMatrix, getReferenceChannel) are inherited from the base IsobaricQuantitationMethod class and don't need to be redeclared explicitly.
Learnt from: FreezB11
PR: OpenMS/OpenMS#7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:4-4
Timestamp: 2025-06-16T15:48:09.667Z
Learning: In OpenMS .pxd files, the established pattern for extern from statements is to include angle brackets inside the string literal, like `cdef extern from "<OpenMS/PATH/TO/FILE.h>" namespace "OpenMS":`. This is consistent across all existing quantitation method .pxd files and other .pxd files in the OpenMS codebase.
src/pyOpenMS/pxds/FeatureGroupingAlgorithm.pxd (2)
Learnt from: FreezB11
PR: OpenMS/OpenMS#7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:4-4
Timestamp: 2025-06-16T15:48:09.667Z
Learning: In OpenMS .pxd files, the established pattern for extern from statements is to include angle brackets inside the string literal, like `cdef extern from "<OpenMS/PATH/TO/FILE.h>" namespace "OpenMS":`. This is consistent across all existing quantitation method .pxd files and other .pxd files in the OpenMS codebase.
Learnt from: FreezB11
PR: OpenMS/OpenMS#7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:1-3
Timestamp: 2025-06-16T15:49:26.504Z
Learning: In OpenMS Python bindings (.pxd files), derived quantitation method classes like TMTThirtyTwoPlexQuantitationMethod only need to declare their constructors. All other public methods (getName, getChannelInformation, getNumberOfChannels, getIsotopeCorrectionMatrix, getReferenceChannel) are inherited from the base IsobaricQuantitationMethod class and don't need to be redeclared explicitly.
src/pyOpenMS/pxds/SpectrumAccessTransforming.pxd (2)
Learnt from: FreezB11
PR: OpenMS/OpenMS#7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:4-4
Timestamp: 2025-06-16T15:48:09.667Z
Learning: In OpenMS .pxd files, the established pattern for extern from statements is to include angle brackets inside the string literal, like `cdef extern from "<OpenMS/PATH/TO/FILE.h>" namespace "OpenMS":`. This is consistent across all existing quantitation method .pxd files and other .pxd files in the OpenMS codebase.
Learnt from: FreezB11
PR: OpenMS/OpenMS#7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:1-3
Timestamp: 2025-06-16T15:49:26.504Z
Learning: In OpenMS Python bindings (.pxd files), derived quantitation method classes like TMTThirtyTwoPlexQuantitationMethod only need to declare their constructors. All other public methods (getName, getChannelInformation, getNumberOfChannels, getIsotopeCorrectionMatrix, getReferenceChannel) are inherited from the base IsobaricQuantitationMethod class and don't need to be redeclared explicitly.
🪛 Ruff (0.12.2)
src/pyOpenMS/pyopenms/_dataframes.py
518-518: Do not use mutable data structures for argument defaults
Replace with None; initialize within function
(B006)
🪛 GitHub Check: CodeFactor
src/pyOpenMS/pyopenms/_dataframes.py
[notice] 517-614: src/pyOpenMS/pyopenms/_dataframes.py#L517-L614
Complex Method
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: build-macos
- GitHub Check: build-lnx
- GitHub Check: build-macos-arm
- GitHub Check: build-win
- GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
🔇 Additional comments (17)
src/pyOpenMS/pxds/FeatureGroupingAlgorithm.pxd (1)
12-15: LGTM! Proper annotation of abstract base class.The addition of
wrap-ignore,ABSTRACT class, andno-pxd-importannotations correctly identifies this as an abstract base class that should not be directly instantiated in Python. This standardization improves the Python bindings by preventing inappropriate usage.src/pyOpenMS/pxds/ConsensusMap.pxd (1)
92-92: LGTM! Correctly exposes method in Python interface.Removing
wrap-ignorefromgetUnassignedPeptideIdentifications()makes this method available in Python, which is consistent with the improvements to peptide identification handling mentioned in the PR.src/pyOpenMS/pxds/SpectrumAccessTransforming.pxd (1)
13-16: LGTM! Consistent annotation standardization.The addition of
wrap-ignore,ABSTRACT class, andno-pxd-importannotations follows the same standardization pattern applied to other abstract base classes in this PR. This correctly identifiesSpectrumAccessTransformingas an abstract class that should not be directly instantiated in Python.src/pyOpenMS/tests/unittests/test000.py (7)
1737-1759: LGTM! Consistent update to use FeatureGroupingAlgorithmQT.The changes correctly update references from
FeatureGroupingAlgorithmtoFeatureGroupingAlgorithmQT, which aligns with theFeatureGroupingAlgorithmclass being marked as abstract and ignored for wrapping.
1873-1874: LGTM! Proper use of PeptideIdentificationList API.The changes correctly update the test to use the new container type:
- Using
.empty()method to check if the container is empty instead of comparing to an empty Python list- Creating a new
PeptideIdentificationList()instance instead of using an empty Python list
1925-1927: LGTM! Correct implementation of PeptideIdentificationList workflow.The code properly demonstrates the new API usage:
- Creates a
PeptideIdentificationListinstance- Uses
.push_back()to add elements- Sets the container on the feature
This follows the expected pattern for the new container type.
1934-1934: LGTM! Appropriate use of container-specific method.Using
.size()instead of Python'slen()is correct for the new container type and maintains the same test logic.
2063-2063: LGTM! Consistent container type usage.The change from Python list to
PeptideIdentificationList()is correct and consistent with the broader refactoring effort.
2088-2088: LGTM! Proper use of container's add method.Using
.push_back()instead of.append()is the correct way to add elements to thePeptideIdentificationListcontainer.Also applies to: 2097-2097
4683-4685: LGTM! Correct PeptideIdentificationList usage in test.The changes properly demonstrate the new container API:
- Creates
PeptideIdentificationListinstances- Uses
.push_back()to add elements- Maintains the same test logic with the new container type
src/pyOpenMS/pyopenms/_dataframes.py (7)
11-11: LGTM: Import addition for PeptideIdentificationListThe import is correctly added to support the type annotation and usage changes throughout the file.
109-111: LGTM: Consistent type annotation and method usageThe changes correctly replace the Python list type annotation with
_PeptideIdentificationListand update the length check to use the.size()method.
246-252: LGTM: Consistent type annotation and method usageThe changes correctly replace the Python list type annotation with
_PeptideIdentificationListand update the length check to use the.size()method.
295-297: LGTM: Return type and initialization updated consistentlyThe return type annotation and variable initialization are correctly updated to use
_PeptideIdentificationListinstead of Python list.
310-310: LGTM: Method call updated for new container typeThe change from
append()topush_back()is correct for the_PeptideIdentificationListcontainer type.
532-532: LGTM: Method call updated for new container typeThe change from
len()to.size()is correct for the_PeptideIdentificationListcontainer type.
617-617: LGTM: Parameter type annotation updatedThe parameter type annotation is correctly updated to use
_PeptideIdentificationListinstead of Python list.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
src/pyOpenMS/pyopenms/_dataframes.py (1)
517-522: Mutable default argument issue still existsThe past review comment correctly identified a mutable default argument issue that should be addressed.
Apply this diff to fix the mutable default argument:
-def peptide_identifications_to_df(peps: _PeptideIdentificationList, decode_ontology : bool = True, - default_missing_values: dict = {bool: False, int: -9999, float: _np.nan, str: ''}, - export_unidentified : bool = True): +def peptide_identifications_to_df(peps: _PeptideIdentificationList, decode_ontology : bool = True, + default_missing_values: dict = None, + export_unidentified : bool = True):Then add initialization inside the function:
+ if default_missing_values is None: + default_missing_values = {bool: False, int: -9999, float: _np.nan, str: ''}
🧹 Nitpick comments (1)
src/pyOpenMS/tests/unittests/test_FileIO.py (1)
27-27: Fix spacing after commasThe static analysis correctly identifies formatting issues with multiple spaces after commas.
Apply this diff to fix the formatting:
- self.assertEqual( len(prots), 3) - self.assertEqual( peps.size(), 19) + self.assertEqual(len(prots), 3) + self.assertEqual(peps.size(), 19)- self.assertEqual( len(prots), 1) - self.assertEqual( peps.size(), 3) + self.assertEqual(len(prots), 1) + self.assertEqual(peps.size(), 3)Also applies to: 50-50
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/pyOpenMS/pxds/StringDataArray.pxd(1 hunks)src/pyOpenMS/pyopenms/_dataframes.py(8 hunks)src/pyOpenMS/tests/unittests/test_FileIO.py(3 hunks)
✅ Files skipped from review due to trivial changes (1)
- src/pyOpenMS/pxds/StringDataArray.pxd
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: FreezB11
PR: OpenMS/OpenMS#7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:4-4
Timestamp: 2025-06-16T15:48:09.667Z
Learning: In OpenMS .pxd files, the established pattern for extern from statements is to include angle brackets inside the string literal, like `cdef extern from "<OpenMS/PATH/TO/FILE.h>" namespace "OpenMS":`. This is consistent across all existing quantitation method .pxd files and other .pxd files in the OpenMS codebase.
Learnt from: FreezB11
PR: OpenMS/OpenMS#7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:1-3
Timestamp: 2025-06-16T15:49:26.504Z
Learning: In OpenMS Python bindings (.pxd files), derived quantitation method classes like TMTThirtyTwoPlexQuantitationMethod only need to declare their constructors. All other public methods (getName, getChannelInformation, getNumberOfChannels, getIsotopeCorrectionMatrix, getReferenceChannel) are inherited from the base IsobaricQuantitationMethod class and don't need to be redeclared explicitly.
src/pyOpenMS/tests/unittests/test_FileIO.py (1)
Learnt from: FreezB11
PR: OpenMS/OpenMS#7969
File: src/pyOpenMS/pxds/TMTThirtyTwoPlexQuantitationMethod.pxd:4-4
Timestamp: 2025-06-16T15:48:09.667Z
Learning: In OpenMS .pxd files, the established pattern for extern from statements is to include angle brackets inside the string literal, like `cdef extern from "<OpenMS/PATH/TO/FILE.h>" namespace "OpenMS":`. This is consistent across all existing quantitation method .pxd files and other .pxd files in the OpenMS codebase.
🪛 Ruff (0.12.2)
src/pyOpenMS/pyopenms/_dataframes.py
518-518: Do not use mutable data structures for argument defaults
Replace with None; initialize within function
(B006)
🪛 GitHub Check: CodeFactor
src/pyOpenMS/pyopenms/_dataframes.py
[notice] 517-614: src/pyOpenMS/pyopenms/_dataframes.py#L517-L614
Complex Method
src/pyOpenMS/tests/unittests/test_FileIO.py
[notice] 27-27: src/pyOpenMS/tests/unittests/test_FileIO.py#L27
Multiple spaces after ','. (E241)
[notice] 50-50: src/pyOpenMS/tests/unittests/test_FileIO.py#L50
Multiple spaces after ','. (E241)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: build-and-test (ubuntu-22.04, g++, 11)
- GitHub Check: build-and-test (ubuntu-22.04, clang++, 15)
- GitHub Check: build-and-test (macos-13, xcode, 14.2)
- GitHub Check: build-and-test (macos-14, xcode, 15.0.1)
- GitHub Check: build-and-test (windows-2022, cl.exe, 14.36)
- GitHub Check: cppcheck-test
🔇 Additional comments (7)
src/pyOpenMS/tests/unittests/test_FileIO.py (3)
15-15: LGTM: Consistent refactoring to PeptideIdentificationListThe changes correctly replace Python lists with
pyopenms.PeptideIdentificationList()instances, aligning with the broader refactoring effort to use more specific container types.Also applies to: 22-22, 39-39, 45-45
27-27: LGTM: Correct method call updatesThe changes from
len(peps)topeps.size()are correct and consistent with thePeptideIdentificationListcontainer interface.Also applies to: 50-50
59-59: LGTM: Minor syntax cleanupThe removal of unnecessary semicolons improves code consistency.
Also applies to: 65-65
src/pyOpenMS/pyopenms/_dataframes.py (4)
11-11: LGTM: Required import for refactoringThe import of
PeptideIdentificationListis necessary for the type system refactoring.
109-109: LGTM: Consistent type annotation updatesThe changes to use
_PeptideIdentificationListinstead oflistare consistent and improve type safety by aligning with the underlying C++ container semantics.Also applies to: 246-246, 295-295, 517-517, 522-522, 617-617
111-111: LGTM: Correct method call updatesThe changes from
len()to.size()are correct and consistent with the_PeptideIdentificationListcontainer interface.Also applies to: 252-252, 532-532
297-297: LGTM: Correct container usageThe changes from
[]to_PeptideIdentificationList()andappend()topush_back()correctly align with the C++ container semantics.Also applies to: 310-310
|
thanks for the cleanup |
|
We could have used wrap-as "append" for push_back and add a |
|
good point as this is a breaking change.will add |
Summary by CodeRabbit
Refactor
Tests
Style