-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Preserve circuit tags in transformer_primitives.map_operations #6505
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6505 +/- ##
=======================================
Coverage 97.76% 97.76%
=======================================
Files 1105 1105
Lines 95028 95047 +19
=======================================
+ Hits 92900 92919 +19
Misses 2128 2128 ☔ View full report in Codecov by Sentry. |
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%nits
) | ||
if isinstance(target_circuit, circuits.FrozenCircuit): | ||
return cast(CIRCUIT_TYPE, circuits.FrozenCircuit(ops).with_tags(*target_circuit.tags)) | ||
return cast(CIRCUIT_TYPE, circuits.Circuit(ops)) |
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.
nit: do we need the cast statements?
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, unfortunately we do need them. Otherwise mypy doesn't understand that the return type matches the type variable on the input arg.
circuit = cirq.FrozenCircuit.from_moments(x, cirq.FrozenCircuit(x)).with_tags(tag) | ||
mapped = cirq.map_operations(circuit, func, deep=deep) | ||
|
||
assert circuit.tags == (tag,) |
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.
why do we check the input circuit here and below?
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.
They're not needed. I will remove because I agree the point is not clear.
Fixes #6504.