-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add __radd__ in Circuit #2418
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
Add __radd__ in Circuit #2418
Conversation
6be3fab to
0382e75
Compare
This commit adds __radd__ in cirq.Circuit() because Moment + Circuit doesn't work even if Circuit + Moment works.
c-poole
left a comment
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.
LGTM! Thanks for the contribution. We'll need an approval from someone with write access before it can be merged, but it shouldn't take too long.
I really appreciate for helping me ramping up for this first PR! :D |
vtomole
left a comment
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.
Add a test that covers
raise ValueError("Can't add circuits with incompatible devices.")to pass the coverage check.and i'll merge it it
|
Please add tests for these lines; |
dabacon
left a comment
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.
Missing coverage for two lines (See my other comment)
|
Nit @dabacon : You don't need to request changes that the build system is already enforcing. |
Perhaps not, but it is a helpful reminder for a first-time contributor. |
|
Yeah, the explanation is certainly a good idea. |
|
Yes, I need to learn more about github system because I am a novice. Thank you all for your kind comments. I will work on the coverage! |
|
I have a question. I realized that radd doesn't require device checking codes inside because (1) add already has it and (2) moment + circuit is converted into cirq.Circuit(moment) + self, which is able to be concatenated with any device. (3) there is no way to set the device of moment, except (4) cirq.Circuit(moment, device=cg.Foxtail) explicitly, for example, then (5) it runs add, not radd. In conclusion, may I just remove the device comparison codes inside radd? |
|
If the error line that the tests don't currently cover is unreachable then the checks that trigger that error are unnecessary and can be removed. You should be able to remove the device checking in |
|
Use backticks ` to avoid the underscores becoming bold Yes, if the other instance is a Circuit then (This is an example of the code coverage check doing a good thing. It effectively noticed the case was impossible!) |
|
Thank you, but I am stuck with coverage. I am very confused. Even if I added test codes, coverage still says my codes are not covered. On top of it, it also says my test codes are not covered! Why are my test codes recognized as tests? LOL. I just ran "./check/pytest-and-incremental-coverage" and the messages are: Running pytest [23/337] Finished pytest |
Oh, I realized that I didn't install pytest-benchmark in my venv. As well, I missed registering upstream yet. Both make coverage happy & green now :D Thank you for your helps! Now I got it! |
This commit adds radd in cirq.Circuit() because Moment + Circuit doesn't work even if Circuit + Moment works.
I've done. Could you give me LGTM? |
|
Love the simpler implementation. |
|
Automerge cancelled: Merging is blocked (I don't understand why). |
This commit adds radd in cirq.Circuit() because Moment + Circuit doesn't work even if Circuit + Moment works.