-
Notifications
You must be signed in to change notification settings - Fork 989
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
Replace _get_op_circuit with op.untagged #3893
Conversation
cirq/circuits/circuit.py
Outdated
@@ -776,13 +776,13 @@ def are_all_matches_terminal(self, predicate: Callable[['cirq.Operation'], bool] | |||
if not all( | |||
self.next_moment_operating_on(op.qubits, i + 1) is None | |||
for (i, op) in self.findall_operations(predicate) | |||
if _get_op_circuit(op) is None | |||
if getattr(op.untagged, 'circuit', None) is None |
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 it would more clearly convey intent here to check the type instead
if getattr(op.untagged, 'circuit', None) is None | |
if not isinstance(op.untagged, CircuitOperation) |
Would have to import CircuitOperation
in are_all_matches_terminal
and are_any_matches_terminal
, but that should be fine. WDYT?
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.
That seems reasonable to me. Change applied (+ imports)
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
Since
Operation
provides a canonical way to get the untagged version of itself, we should use it instead of writing a new method to do the same thing.Using
op.untagged
in #3634 removes any residual blocking effects from #3678, although I'm still in favor of finding a proper resolution to #3678.