Skip to content
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

fix phase_by protocol for tagged operations #6792

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cirq-core/cirq/ops/raw_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,9 @@ def _trace_distance_bound_(self) -> float:
return protocols.trace_distance_bound(self.sub_operation)

def _phase_by_(self, phase_turns: float, qubit_index: int) -> 'cirq.Operation':
return protocols.phase_by(self.sub_operation, phase_turns, qubit_index)
return protocols.phase_by(
self.sub_operation, phase_turns, qubit_index, default=NotImplemented
)

def __pow__(self, exponent: Any) -> 'cirq.Operation':
return self.sub_operation**exponent
Expand Down
1 change: 1 addition & 0 deletions cirq-core/cirq/ops/raw_types_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ def test_tagged_operation_forwards_protocols():
assert cirq.commutes(tagged_x, clifford_x)
assert cirq.commutes(clifford_x, tagged_x)
assert cirq.commutes(tagged_x, tagged_x)
assert cirq.phase_by(tagged_x, 0.125, 1, default=None) is None
richrines1 marked this conversation as resolved.
Show resolved Hide resolved

assert cirq.trace_distance_bound(y**0.001) == cirq.trace_distance_bound(
(y**0.001).with_tags(tag)
Expand Down