-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Reducing some code by cleaning up some logic #6003
Conversation
…around in circuit.py
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.
Thank you for the PR! I agree two of the changes improve the code. Before merging, I would like to ask you to revert one of them to avoid repeated checks in a loop, see below.
cirq-core/cirq/circuits/circuit.py
Outdated
active.remove(q) | ||
elif q in active: | ||
end_frontier[q] = cur_moment | ||
active.remove(q) |
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.
This is shorter, but tests the condition on each iteration. I think the previous code is slightly better.
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.
makes sense to me! pushed.
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.
Thank you!
* reducing some indenting and amount of reading by changing some logic around in circuit.py * reverting change per code review --------- Co-authored-by: Adam Zalcman <40255865+viathor@users.noreply.github.com>
Reading through, I noticed some things could be combined to reduce reading and indentation.