Skip to content

Commit

Permalink
Fix stim.Circuit.to_tableau ignoring SPP and SPP_DAG
Browse files Browse the repository at this point in the history
- Fix `SPP` not being classified as a unitary gate
- Fix `SPP_DAG` not being classified as a unitary gate

Fixes #846
  • Loading branch information
Strilanc committed Oct 28, 2024
1 parent 34b4168 commit cec9e6c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/stim/circuit/circuit_pybind_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,6 @@ def test_likeliest_error_sat_problem():
DETECTOR rec[-1] rec[-2]
""")
sat_str = c.likeliest_error_sat_problem(quantization=100)
print(sat_str)
assert sat_str == 'p wcnf 2 4 401\n18 -1 0\n100 -2 0\n401 -1 0\n401 2 0\n'


Expand Down Expand Up @@ -1902,3 +1901,14 @@ def test_pop():
def test_circuit_create_with_odd_cx():
with pytest.raises(ValueError, match="0, 1, 2"):
stim.Circuit("CX 0 1 2")


def test_to_tableau():
assert stim.Circuit().to_tableau() == stim.Tableau(0)
assert stim.Circuit("QUBIT_COORDS 0").to_tableau() == stim.Tableau(1)
assert stim.Circuit("I 0").to_tableau() == stim.Tableau(1)
assert stim.Circuit("H 0").to_tableau() == stim.Tableau.from_named_gate("H")
assert stim.Circuit("CX 0 1").to_tableau() == stim.Tableau.from_named_gate("CX")
assert stim.Circuit("SPP Z0").to_tableau() == stim.Tableau.from_named_gate("S")
assert stim.Circuit("SPP X0").to_tableau() == stim.Tableau.from_named_gate("SQRT_X")
assert stim.Circuit("SPP_DAG Y0*Y1").to_tableau() == stim.Tableau.from_named_gate("SQRT_YY_DAG")
4 changes: 2 additions & 2 deletions src/stim/gates/gate_data_pauli_product.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ S 1
.id = GateType::SPP,
.best_candidate_inverse_id = GateType::SPP_DAG,
.arg_count = 0,
.flags = (GateFlags)(GATE_TARGETS_PAULI_STRING | GATE_TARGETS_COMBINERS),
.flags = (GateFlags)(GATE_TARGETS_PAULI_STRING | GATE_TARGETS_COMBINERS | GATE_IS_UNITARY),
.category = "P_Generalized Pauli Product Gates",
.help = R"MARKDOWN(
The generalized S gate. Phases the -1 eigenspace of Pauli product observables by i.
Expand Down Expand Up @@ -174,7 +174,7 @@ CX 2 1
.id = GateType::SPP_DAG,
.best_candidate_inverse_id = GateType::SPP,
.arg_count = 0,
.flags = (GateFlags)(GATE_TARGETS_PAULI_STRING | GATE_TARGETS_COMBINERS),
.flags = (GateFlags)(GATE_TARGETS_PAULI_STRING | GATE_TARGETS_COMBINERS | GATE_IS_UNITARY),
.category = "P_Generalized Pauli Product Gates",
.help = R"MARKDOWN(
The generalized S_DAG gate. Phases the -1 eigenspace of Pauli product observables by -i.
Expand Down

0 comments on commit cec9e6c

Please sign in to comment.