-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Comparing matrix with object #20175
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
Comparing matrix with object #20175
Conversation
✅ Hi, I am the SymPy bot (v161). 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.8. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
@oscarbenjamin Does it seems right? |
Codecov Report
@@ Coverage Diff @@
## master #20175 +/- ##
=============================================
- Coverage 75.855% 75.775% -0.081%
=============================================
Files 671 674 +3
Lines 173793 174226 +433
Branches 41047 41117 +70
=============================================
+ Hits 131832 132020 +188
- Misses 36206 36485 +279
+ Partials 5755 5721 -34 |
Always add test cases that will fail without the changes you make. This ensures that the problem does not occur in the future. |
There is a decorator |
Done |
Used it , decorator really easied it. |
@oscarbenjamin pls review |
@friyaz Removed comments. Does everything else seems fine? |
Looks good to me. |
@oscarbenjamin @friyaz dont think using decorator is a good way because it is making other test fail |
@oscarbenjamin @friyaz I dont think using decorator is a good way because it is making other test fail. |
@oscarbenjamin @friyaz So shall I drop the decorator and use the method of 1st commit? |
This way is better as it doesn't break anything. Decorator breaks the code |
@oscarbenjamin Does it seems right now?? |
Why didn't the decorator work? |
Decorator broke the code , and gave way too many failures |
Can you give an example of something that didn't work? |
https://travis-ci.org/github/sympy/sympy/builds/732235398 See the build at travis , all 4 test failed, test files and doc tests. |
@oscarbenjamin Is it good without decorator? |
Yes, it should be fine but we should check why it didn't work with the decorator. Maybe the decorator can be improved or maybe it's just not suitable for this. Without investigating the failures we won't know. |
Okay , i'll look into it as much as I can |
The number of test failures suggest decorator isn't suitable for this. Because the number of failures are really high and are in almost every module |
@oscarbenjamin What do you say? Is is good to go? |
Why doesn't the decorator work? The error from the test logs is
That suggests that the decorator wasn't used correctly. |
I'll give it another try |
@oscarbenjamin Is it good to go now?? |
def __eq__(self, other): | ||
other = sympify(other) | ||
self_shape = getattr(self, 'shape', None) | ||
other_shape = getattr(other, 'shape', None) | ||
if None in (self_shape, other_shape): |
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.
The conditions below suggest that sometimes other
is not a DenseMatrix
. Is that not ever the case?
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.
It works for all cases .
@oscarbenjamin I have checked and updates test file with other Matrix types also. It works as expected. |
@oscarbenjamin Please review. |
Since @oscarbenjamin is busy with 1.7 update. Can someone else review please.I think it is good to go. |
Can someone please review |
@sylee957 Please review. |
Since no one is reviewing, @oscarbenjamin please review it when free |
Can someone please review this PR. |
sympy/matrices/dense.py
Outdated
class DenseMatrix(MatrixBase): | ||
|
||
is_MatrixExpr = False # type: bool | ||
|
||
_op_priority = 10.01 | ||
_class_priority = 4 | ||
|
||
@sympify_return([('other', 'DenseMatrix')], NotImplemented) |
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.
Can't we add this to SparseMatrix such that it can be symmetric change?
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.
okay , would do that.
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.
The decorator can be used when sympifying code, since the SparseMatrix isn't sympifying , it shouldn't be added in SparseMatrix
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.
I'd rather change that SparseMatrix to sympify the arguments before calls
It is problematic if operations supported in DenseMatrix is not supported by SparseMatrix only because of sympify
For example,
from sympy import *
import mpmath
m = mpmath.matrix([[1, 2], [3, 4]])
Matrix([[1, 2], [3, 4]]) == m # True
SparseMatrix([[1, 2], [3, 4]]) == m # False
@sylee957 @oscarbenjamin I have removed the decorator and used _sympify instead . |
@sidhu1012 we are having problems with CI (#20289). The tests are unlikely to pass for these PRs until that is resolved. I cancelled the previous run of the tests because because they were slowing down the tests for #20297 |
@oscarbenjamin Okay , please review this PR though |
@oscarbenjamin @sylee957 Please review |
References to other Issues or PRs
Fixes #19361
Brief description of what is fixed or changed
Corrected eq() of Matrix
Other comments
Release Notes
- Changed behaviour of eq() of class DenseMatrix