Repository navigation
Fix Typo In Matrix - #8272
Fix Typo In Matrix#8272
Conversation
WalkthroughAdded a non-const Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Test / User
participant Matrix as Matrix<T>
participant Storage as internal data (operator())
Note over Matrix: New API: getValue(i,j) -> Value&\nConst getValue calls this->operator()(i,j)
Caller->>Matrix: getValue(i,j)
alt non-const
Matrix->>Storage: operator()(i,j) (returns reference)
Storage-->>Matrix: Value&
Matrix-->>Caller: Value& (modifiable)
else const
Matrix->>Storage: this->operator()(i,j) (const access)
Storage-->>Matrix: const Value&
Matrix-->>Caller: const Value&
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ 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 |
|
Could you add a line in the class and pyopenms test please? |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/pyOpenMS/tests/unittests/test000.py (1)
4100-4106: Consider expanding test to demonstrate modification through getValue.The C++ test in
Matrix_test.cpp(lines 159-180) demonstrates that the non-constgetValuemethod returns a modifiable reference, allowing both assignment (getValue(0, 0) = 100) and modification (getValue(0, 0) += 5). This Python test only verifies read access by usingsetValuefor writes andgetValuefor reads.If the Python bindings expose a non-const
getValuethat supports modification, consider adding test cases that match the C++ test pattern:# Test modification through getValue test_matrix = pyopenms.MatrixDouble(2, 2, 0.0) test_matrix.getValue(0, 0) = 100.0 # If supported assert test_matrix.getValue(0, 0) == 100.0If modification through
getValueis not supported in Python, the current test is appropriate but could include a comment explaining this difference from the C++ API.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/pyOpenMS/tests/unittests/test000.py(1 hunks)src/tests/class_tests/openms/source/Matrix_test.cpp(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/tests/class_tests/openms/**/*.cpp
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Write unit tests for new functionality
Files:
src/tests/class_tests/openms/source/Matrix_test.cpp
src/pyOpenMS/tests/**/*.py
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Write pyOpenMS tests for new Python bindings
Files:
src/pyOpenMS/tests/unittests/test000.py
🧬 Code graph analysis (1)
src/tests/class_tests/openms/source/Matrix_test.cpp (1)
src/openms/include/OpenMS/DATASTRUCTURES/Matrix.h (1)
getValue(76-79)
🔇 Additional comments (1)
src/tests/class_tests/openms/source/Matrix_test.cpp (1)
159-180: LGTM! Comprehensive test coverage for non-const getValue.The test thoroughly verifies the non-const
getValuemethod by:
- Testing direct assignment through the returned reference (
getValue(i, j) = value)- Testing in-place modification (
getValue(i, j) += value)- Properly verifying the results using
operator()This aligns well with the C++ API design and ensures the new method works correctly.
Description
There was a typo in
Matrix.hwhich caused issues with FLASHDeconv.Due to operator precedence:
*this(i, j)is parsed as:
*(this(i, j))instead of the intended:
(*this)(i, j)This PR replaces it with the more explicit:
which also matches the style used in the rest of the header.
Credit goes to @KyowonJeong .
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
New Features
Refactor
Tests