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
Checked if subs argument was zip object and added test #19159
Conversation
gfolbe318
commented
Apr 21, 2020
•
edited by czgdp1807
edited by czgdp1807
- matrices
- changed subs function to check if input is zip
- added tests in test_commonmatrix.py
✅ 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. |
Codecov Report
@@ Coverage Diff @@
## master #19159 +/- ##
=========================================
Coverage 75.849% 75.849%
=========================================
Files 670 670
Lines 173699 173701 +2
Branches 40978 40979 +1
=========================================
+ Hits 131750 131752 +2
- Misses 36209 36213 +4
+ Partials 5740 5736 -4 |
Please refer this and other PR comments for writing proper PR template. Also, add a short description about what you changed and what gets fixed. |
@@ -2118,6 +2118,10 @@ def subs(self, *args, **kwargs): # should mirror core.basic.subs | |||
>>> Matrix(_).subs(y, x) | |||
Matrix([[x]]) | |||
""" | |||
|
|||
if isinstance(args[0], zip): | |||
args = (list(args[0]),) |
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.
There are other possibilities for what args[0] could be that would have this problem e.g. map etc (athough zip is most common).
I think it would be better to do something like convert args to a tuple if whenever it is not a tuple.
Also this would ignore args[1] etc if supplied.
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.
Hey @oscarbenjamin, thanks for the feedback. In all honesty, I didn't realize that creating a fork of the repository would still notify contributors of any pull requests I made...rookie mistake! I tried inputs on maps and those seemed to work. I'll now try to enhance this pull request like you suggested and also add test cases as well as some release notes.
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.
Also, would you recommend that I create a completely new PR? Or can I just modify this one?
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.
Or can I just modify this one?
Modifying this one should do.
@smitgajjar I will add release notes, but I also have to modify some other files and write test cases. Should I close this PR and make another? Sorry, I am new to this. |
You can continue making commits on this branch (i.e. updating other files or adding tests). No need to make a new PR. |
Refer the Sympy's development workflow, especially patch updates here :) |
🟠Hi, I am the SymPy bot (v160). I've noticed that some of your commits add or delete files. Since this is sometimes done unintentionally, I wanted to alert you about it. This is an experimental feature of SymPy Bot. If you have any feedback on it, please comment at sympy/sympy-bot#75. The following commits add new files:
The following commits delete files:
If these files were added/deleted on purpose, you can ignore this message. |
I did some thought about this error and came to the conclusion that this issue might be a little more difficult than I previously expected. Here is why: The change proposed in #19159 (comment) will not work because (from my understanding), all input types that are not iterators work perfectly. Simply casting the argument to a tuple (if it is not so already) will cause inputs that are dictionaries and sets to fail and will result in a lot of code duplication from sympy/core/basic.py. It is also worth noting that when len(args) == 2, iterators are not valid inputs to the subs function. The original piece of code I added should fix the issue it is addressing, but I am open to keep working on it to make it more generalized. I can also try something like this:
Essentially, how would I go about identifying that my data structure is iterable but is not a map or set without code duplication? (Sorry for the multiple edits) |
One possibility would be to do something like:
I'm wondering though whether it might be better to punt entirely on trying to reimplement and part of subs (which is already implemented for Basic) and do:
|
@gfolbe318 Would you like to complete this PR? Please resolve the conflicts. Thanks for your contributions. Please do not close this PR. |
Hello, yes. I apologize for the gaps in communication. I will take a closer look at it ! |
Just got back to this, apologies again for the delays. Things have been pretty hectic. I think my most recent fix should be good. I tried both of @oscarbenjamin 's suggestions and ended up going with the first one, as the second caused a recursion error. Hopefully I merged everything in correctly. Another thing I am struggling with is getting the release notes check to pass. Please let me know if you see any glaring errors with what I wrote. I have read the guidelines multiple times and looked at other examples, so I am assuming that I'm missing something small. |
The Travis CI build failed, but after doing some investigation I read that it could've been due to a failed HTTP connection. How could I go about rerunning the build without committing a change? |
I have resolved the conflicts. @gfolbe318 Can you see if it is okay? @oscarbenjamin Is there anything more to be done to let it in master? |
Yes, this is good. Thanks! |
Thanks everyone! |