Skip to content

Commit

Permalink
Fix odd-target-count-for-two-qubit-gate error message (#831)
Browse files Browse the repository at this point in the history
- Was writing the arguments instead of the targets into the message

Fixes #817
  • Loading branch information
Strilanc authored Sep 21, 2024
1 parent c5830cd commit 3ee5bf8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/stim/circuit/circuit_instruction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void CircuitInstruction::validate() const {
"Two qubit gate " + std::string(gate.name) +
" requires an even number of targets but was given "
"(" +
comma_sep(args).str() + ").");
comma_sep(targets).str() + ").");
}
for (size_t k = 0; k < targets.size(); k += 2) {
if (targets[k] == targets[k + 1]) {
Expand Down
5 changes: 5 additions & 0 deletions src/stim/circuit/circuit_pybind_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1879,3 +1879,8 @@ def test_insert():
M 2
H 1
""")


def test_circuit_create_with_odd_cx():
with pytest.raises(ValueError, match="0, 1, 2"):
stim.Circuit("CX 0 1 2")

0 comments on commit 3ee5bf8

Please sign in to comment.