-
Notifications
You must be signed in to change notification settings - Fork 61
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
Fix scalar mutliplication of SymbolicTerm
#474
Conversation
Codecov Report
@@ Coverage Diff @@
## master #474 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 84 85 +1
Lines 11770 11905 +135
==========================================
+ Hits 11770 11905 +135
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
I simplified a little bit the |
src/qibo/core/terms.py
Outdated
matrix_map (dict): Dictionary that maps target qubit ids to a list of | ||
matrices that act on each qubit. | ||
""" | ||
"""Helper constructor using the ``sympy`` expression directly. |
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 think there is something wrong with this comment, no?
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.
Yes, thanks. I was going to update the docstring after removing the .from_factors
constructor for simplification but I forgot to complete the update. It should be ok now.
|
||
if isinstance(factor, sympy.Symbol): | ||
if isinstance(factor.matrix, K.qnp.tensor_types): | ||
self.factors.extend(pow * [factor]) |
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.
Given that the comments are quite good, please some sentence explaining how and why the pow term is applied to the matrix_map.
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.
Thanks for this implementation. Works for me, seems to fix the non convergence observed in the notebooks. Please a look at my minor comments.
Thank you for the review. I update the comments for the above points, let me know if it is ok. |
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.
Looks good, thank you.
Fixes #470, the fix was very simple and is in the first commit only. In the rest I am adding some unit tests that focus on the
core/terms.py
file and improving the related docstrings and comments to help in the future, because as it is now it was quite hard to debug this issue.