Skip to content

Commit

Permalink
Fix ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
Strilanc committed Feb 5, 2024
1 parent 86b482e commit 0dbc634
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/stim/circuit/export_qasm.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -636,17 +636,17 @@ measure q[0] -> rec[3];
cx q[1], q[0];
// --- end decomposed MPP
hyz q[6];
cx q[4], q[3];
cx q[6], q[3];
cx q[4], q[3];
h q[4];
h q[5];
cx q[5], q[4];
cz q[3], q[4];
cx q[5], q[4];
h q[4];
h q[5];
cx q[6], q[3];
cx q[4], q[3];
cx q[6], q[3];
hyz q[8];
hyz q[7];
hyz q[6];
Expand Down
4 changes: 2 additions & 2 deletions src/stim/circuit/export_qasm_pybind_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ def test_to_qasm2_runs_in_qiskit():
stim_circuit = stim.Circuit("""
R 0 1
MZZ !0 1
MPAD 1
MPAD 0 0
""")
qasm = stim_circuit.to_qasm(open_qasm_version=2)

qiskit_circuit = qiskit.QuantumCircuit.from_qasm_str(qasm)
counts = qiskit_aer.AerSimulator().run(qiskit_circuit, shots=8).result().get_counts(qiskit_circuit)
assert counts['1'] == 8
assert counts['001'] == 8


def test_to_qasm3_parses_in_qiskit():
Expand Down
2 changes: 1 addition & 1 deletion src/stim/py/stim_pybind_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_targets():

def test_gate_data():
data = stim.gate_data()
assert len(data) == 67
assert len(data) == 70
assert data["CX"].name == "CX"
assert data["CX"].aliases == ["CNOT", "CX", "ZCX"]
assert data["X"].is_unitary
Expand Down
8 changes: 6 additions & 2 deletions src/stim/simulators/transform_without_feedback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,19 @@ struct WithoutFeedbackHelper {
throw std::invalid_argument("Unknown feedback gate.");
}
} else if (!b1 && !b2) {
reversed_semi_flattened_output.safe_append(op_piece);
reversed_semi_flattened_output.operations.push_back(CircuitInstruction{
op_piece.gate_type,
reversed_semi_flattened_output.arg_buf.take_copy(op_piece.args),
reversed_semi_flattened_output.target_buf.take_copy(op_piece.targets),
});
}
tracker.undo_gate(op_piece);
}

for (const auto &e : obs_changes) {
if (!e.second.empty()) {
reversed_semi_flattened_output.arg_buf.append_tail((double)e.first);
reversed_semi_flattened_output.safe_append(CircuitInstruction{
reversed_semi_flattened_output.operations.push_back(CircuitInstruction{
GateType::OBSERVABLE_INCLUDE,
reversed_semi_flattened_output.arg_buf.commit_tail(),
reversed_semi_flattened_output.target_buf.take_copy(e.second.range()),
Expand Down

0 comments on commit 0dbc634

Please sign in to comment.