Skip to content

Conversation

@Zeroto521
Copy link
Contributor

closes to #1065

@Zeroto521 Zeroto521 changed the title Feature: MatrixVariable comparison (<=, >= , ==) now supports numpy broadcast feature. Feature: MatrixVariable supports numpy broadcast feature. Oct 24, 2025
@Zeroto521 Zeroto521 changed the title Feature: MatrixVariable supports numpy broadcast feature. Feature: MatrixVariable supports numpy broadcast feature Oct 24, 2025
@Joao-Dionisio Joao-Dionisio requested a review from Copilot October 24, 2025 15:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds numpy broadcasting support to MatrixVariable comparison operations (<=, >=, ==), allowing matrix variables to be compared with arrays of different but compatible shapes. The implementation replaces explicit shape checking with numpy's broadcast function.

Key Changes:

  • Refactored _matrixexpr_richcmp to use np.broadcast for array comparisons instead of strict shape matching
  • Added test coverage for the broadcasting feature
  • Cleaned up unused imports

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/pyscipopt/matrix.pxi Implements numpy broadcasting by replacing shape validation with np.broadcast and using it to iterate over broadcasted elements
tests/test_matrix_variable.py Adds test for broadcasting feature and removes unused imports
CHANGELOG.md Documents the new broadcasting support in MatrixVariable comparisons

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Joao-Dionisio
Copy link
Member

Thank you, @Zeroto521 !

By the way, since you're now an expert on these things, do you have a suggestion for fixing #937 ?

@Joao-Dionisio Joao-Dionisio merged commit 6cdb132 into scipopt:master Oct 30, 2025
1 check passed
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