Skip to content

Commit

Permalink
Fix handling of cargs in BasicQisVisitor
Browse files Browse the repository at this point in the history
The unit tests in this commit fail without the change made to file
src/qiskit_qir/visitor.py.
  • Loading branch information
Julien Dumazert committed Apr 3, 2023
1 parent 458c2d3 commit e8285fa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/qiskit_qir/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def process_composite_instruction(
)
for (inst, i_qargs, i_cargs) in subcircuit.data:
mapped_qbits = [qargs[subcircuit.qubits.index(i)] for i in i_qargs]
mapped_clbits = [cargs[subcircuit.clbits.index] for i in i_cargs]
mapped_clbits = [cargs[subcircuit.clbits.index(i)] for i in i_cargs]
_log.debug(
f"Processing sub-instruction {inst.name} with mapped qubits {mapped_qbits}"
)
Expand Down
1 change: 1 addition & 0 deletions tests/test_circuits/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"teleport",
"unroll",
"teleport_with_subroutine",
"measure_x_as_subroutine"
] + random_fixtures

noop_tests = ["bernstein_vazirani_with_delay", "ghz_with_delay"]
15 changes: 15 additions & 0 deletions tests/test_circuits/basic_circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,18 @@ def ghz_with_delay():
circuit.measure([0, 1, 2], [0, 1, 2])

return circuit

@pytest.fixture()
def measure_x_as_subroutine():
measure_x_circuit = QuantumCircuit(1, 1, name='measure_x')
measure_x_circuit.h(0)
measure_x_circuit.measure(0, 0)
measure_x_circuit.h(0)
measure_x_gate = measure_x_circuit.to_instruction()
qq = QuantumRegister(1, name="qq")
cr = ClassicalRegister(1, name="cr")
circuit = QuantumCircuit(qq, cr)
circuit.name = "Qiskit Sample - Measure in the X-basis as a subroutine"
circuit.append(measure_x_gate, [0], [0])

return circuit

0 comments on commit e8285fa

Please sign in to comment.