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
Enforce elementwise mul for explicit non-matrix #19533
Conversation
✅ Hi, I am the SymPy bot (v160). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like: This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.7. Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
Why should the default values of |
This checks if |
Okay, I get that they are set true only to skip the shape check, |
That's a fair point but I'm unsure which one is better. |
Codecov Report
@@ Coverage Diff @@
## master #19533 +/- ##
=============================================
+ Coverage 75.651% 75.665% +0.013%
=============================================
Files 652 654 +2
Lines 169712 169941 +229
Branches 40051 40066 +15
=============================================
+ Hits 128390 128586 +196
- Misses 35720 35738 +18
- Partials 5602 5617 +15 |
For consistency with the old behavior, I don't think that it's better to silently use
now attempts to multiply with invalid shape, rather than raising I'm not sure that |
So
|
Although |
e051ad3
to
2845eb2
Compare
Very fair point, my bad. I reverted it to my orginal changes and switched to I added a "foo:" test for it and I can add the one above to make sure it still fails as expected. |
5629864
to
6292e3e
Compare
References to other Issues or PRs
Brief description of what is fixed or changed
This PR slightly increase the checks in a Matrix mul so that if multiplied by an object that is explicitly not a matrix, it defaults back to elementwise.
Other comments
This is an issue we run into in Devito, as we have
sympy.Function
andsympy.Symbols
object but with associated data and shape. These objects are non-matrix (will be made explicit with upcoming tensor algebra update) but error when we try to multiply a Matrix.for example:
error as
b.shape = (10, 10)
(so has shape) andlen(b.shape) == 2
so mul thinks b is a matrix and tries to do a MatMat mul with incompatible shapes.Release Notes