Skip to content

prevent Matrix::operator== throwing an assert within Eigen3 - #8305

Merged
timosachsenberg merged 1 commit into
OpenMS:developfrom
cbielow:matrix_fix
Oct 16, 2025
Merged

timosachsenberg merged 1 commit into
OpenMS:developfrom
cbielow:matrix_fix

Conversation

@cbielow

@cbielow cbielow commented Oct 16, 2025 •

Copy link
Copy Markdown
Contributor

Description

when comparing different-sized matrices

(probably depends on the Eigen3 version, if this faulted before or not-- but it did on my machine).

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

How can I get additional information on failed tests during CI

Click to expand If your PR is failing you can check out

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.
  • setting the label "NoJenkins" will skip tests for this PR on jenkins (saves resources e.g., on edits that do not affect tests)
  • commenting with rebuild jenkins will retrigger Jenkins-based CI builds

⚠️ Note: Once you opened a PR try to minimize the number of pushes to it as every push will trigger CI (automated builds and test) and is rather heavy on our infrastructure (e.g., if several pushes per day are performed).

Summary by CodeRabbit

  • Bug Fixes
    • Matrix equality comparison now validates matching dimensions, preventing undefined behavior when comparing matrices of different sizes. Debug mode will raise an exception if dimensions mismatch.

@cbielow
cbielow enabled auto-merge (squash) October 16, 2025 12:10
@coderabbitai

coderabbitai Bot commented Oct 16, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The Matrix::operator== function is enhanced with a precondition check that validates both matrices have identical dimensions before performing the equality comparison. The check uses OPENMS_PRECONDITION to enforce this constraint, raising an exception in debug mode if dimensions mismatch.

Changes

Cohort / File(s) Summary
Matrix equality operator validation
src/openms/include/OpenMS/DATASTRUCTURES/Matrix.h
Added dimension precondition check to operator== prior to Eigen-based comparison; no signature changes

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • timosachsenberg

Poem

🐰 Dimensions must align, oh matrices so fine,
Before we check if you and I are the same design,
A precondition guards the gate,
No mismatched shapes to seal our fate!
hops contentedly

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "prevent Matrix::operator== throwing an assert within Eigen3" is clearly and directly related to the main change in the changeset. The implementation adds an OPENMS_PRECONDITION check to validate that matrices have identical dimensions before delegating to Eigen's comparison operator, which prevents potential assertions from being thrown by Eigen when comparing different-sized matrices. The title is concise, specific, and accurately summarizes the primary objective without vague terminology or unnecessary details. A reviewer scanning the commit history would immediately understand this change addresses preventing assertion failures in matrix equality comparisons.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 499a5f1 and 33a38e7.

📒 Files selected for processing (1)
  • src/openms/include/OpenMS/DATASTRUCTURES/Matrix.h (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/openms/**/*.{cpp,h,hpp,cc,cxx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/openms/**/*.{cpp,h,hpp,cc,cxx}: Follow the existing C++ coding conventions in the codebase
Use the established naming patterns for classes, methods, and variables
Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)
Follow the established error handling patterns
Utilize OpenMS logging mechanisms
Be mindful of memory usage when processing large datasets
Consider algorithmic complexity for data processing operations
Use appropriate OpenMS containers and algorithms

Files:

  • src/openms/include/OpenMS/DATASTRUCTURES/Matrix.h
src/openms/include/OpenMS/**/*.h

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Add Doxygen comments for new public methods and classes

Files:

  • src/openms/include/OpenMS/DATASTRUCTURES/Matrix.h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants