Skip to content

Commit 6b9ec8b

Browse files
Manually resolve conflict and complete cherry-pick
1 parent 1da85cf commit 6b9ec8b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

cirq-core/cirq/ops/pauli_string_test.py

+22
Original file line numberDiff line numberDiff line change
@@ -2137,3 +2137,25 @@ def test_resolve(resolve_fn):
21372137
pst = cirq.PauliString({q: 'x'}, coefficient=t)
21382138
ps1 = cirq.PauliString({q: 'x'}, coefficient=1j)
21392139
assert resolve_fn(pst, {'t': 1j}) == ps1
2140+
2141+
def test_pauli_sum_identity_operations():
2142+
q = cirq.LineQubit(0)
2143+
paulis = tuple(cirq.PauliString(p) for p in (cirq.I(q), cirq.X(q), cirq.Y(q), cirq.Z(q)))
2144+
2145+
def add(x, y):
2146+
return x + y
2147+
2148+
def sub(x, y):
2149+
return x - y
2150+
2151+
def addm(x, y):
2152+
return x + (-1.0) * y
2153+
2154+
for p1 in paulis:
2155+
for p2 in paulis:
2156+
for op in (add, sub, addm):
2157+
try:
2158+
_ = op(p1, p2)
2159+
except Exception as e:
2160+
import pytest
2161+
pytest.fail(f"Operation {p1.gate}{getattr(op, 'sym', op.__name__)}{p2.gate} raised {e}")

0 commit comments

Comments
 (0)