-
Notifications
You must be signed in to change notification settings - Fork 271
Feature: MatrixVariable supports numpy broadcast feature
#1092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
MatrixVariable comparison (<=, >= , ==) now supports numpy broadcast feature.MatrixVariable supports numpy broadcast feature.
MatrixVariable supports numpy broadcast feature.MatrixVariable supports numpy broadcast feature
There was a problem hiding this 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_richcmpto usenp.broadcastfor 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.
Co-authored-by: Copilot <[email protected]>
|
Thank you, @Zeroto521 ! By the way, since you're now an expert on these things, do you have a suggestion for fixing #937 ? |
closes to #1065