-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add Circuit.zip method #3075
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 Circuit.zip method #3075
Conversation
dstrain115
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.
Just one small comment then LGTM.
| assert cirq.Circuit().zip(cirq.Circuit(cirq.Moment())) == cirq.Circuit( | ||
| cirq.Moment()) | ||
|
|
||
| assert circuit1.zip(circuit2) == circuit2.zip(circuit1) == cirq.Circuit( |
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.
Do you want to have a line comment above this and below here, since there is a heading above for empty cases, but it is not visually clear where the section of "Empty cases" ends.
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.
Done.
| >>> circuit1 = cirq.Circuit(cirq.H(a), cirq.CNOT(a, b)) | ||
| >>> circuit2 = cirq.Circuit(cirq.X(c), cirq.Y(c), cirq.Z(c)) | ||
| >>> circuit3 = cirq.Circuit(cirq.Moment(), cirq.Moment(cirq.S(d))) | ||
| >>> print(circuit1.zip(circuit2)) |
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.
Having this as an instance method feels strange because this isn't how it is done in python?
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's a bit unusual but makes sense to me. Because of how Python binds methods, both Circuit.merge(c1, c2) and c1.merge(c2) will work.
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 just start getting scared when we hit line 1269 in a single class definition :)
Handy to have around when building circuits up in tiled pieces and wanting to guarantee the moment structure comes out right.
Handy to have around when building circuits up in tiled pieces and wanting to guarantee the moment structure comes out right.