Skip to content

Commit ee2d32a

Browse files
authored
add _phase_by_ method to ZZPowGate (#6062)
1 parent 8ac690d commit ee2d32a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

cirq-core/cirq/ops/parity_gates.py

+3
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ def _apply_unitary_(self, args: 'protocols.ApplyUnitaryArgs') -> Optional[np.nda
296296

297297
return args.target_tensor
298298

299+
def _phase_by_(self, phase_turns: float, qubit_index: int) -> "ZZPowGate":
300+
return self
301+
299302
def __str__(self) -> str:
300303
if self._exponent == 1:
301304
return 'ZZ'

cirq-core/cirq/ops/parity_gates_test.py

+6
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ def test_zz_pow():
195195
assert (cirq.ZZ**-1) ** 0.5 == cirq.ZZ**-0.5
196196

197197

198+
def test_zz_phase_by():
199+
assert cirq.phase_by(cirq.ZZ, 0.25, 0) == cirq.phase_by(cirq.ZZ, 0.25, 1) == cirq.ZZ
200+
assert cirq.phase_by(cirq.ZZ**0.5, 0.25, 0) == cirq.ZZ**0.5
201+
assert cirq.phase_by(cirq.ZZ**-0.5, 0.25, 1) == cirq.ZZ**-0.5
202+
203+
198204
def test_zz_str():
199205
assert str(cirq.ZZ) == 'ZZ'
200206
assert str(cirq.ZZ**0.5) == 'ZZ**0.5'

0 commit comments

Comments
 (0)