From 054b7ad226ae6e4946089989cbce44ac747c66f3 Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Mon, 27 Nov 2023 15:33:36 -0800 Subject: [PATCH] Fixing wrong qubit id in id gate (#46) * Fixing wrong qubit id in id gate * Updating id usage to avoid non-default id --- src/qiskit_qir/visitor.py | 5 +++-- tests/test_circuits/basic_circuits.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/qiskit_qir/visitor.py b/src/qiskit_qir/visitor.py index c82c6ce..cfcabbb 100644 --- a/src/qiskit_qir/visitor.py +++ b/src/qiskit_qir/visitor.py @@ -346,8 +346,9 @@ def __branch(): qis.z(self._builder, *qubits) elif "id" == instruction.name: # See: https://github.com/qir-alliance/pyqir/issues/74 - qis.x(self._builder, pyqir.qubit(self._module.context, 0)) - qis.x(self._builder, pyqir.qubit(self._module.context, 0)) + qubit = pyqir.qubit(self._module.context, qubit_id(*qubits)) + qis.x(self._builder, qubit) + qis.x(self._builder, qubit) elif instruction.definition: _log.debug( f"About to process composite instruction {instruction.name} with qubits {qargs}" diff --git a/tests/test_circuits/basic_circuits.py b/tests/test_circuits/basic_circuits.py index 532b53b..1ec0107 100644 --- a/tests/test_circuits/basic_circuits.py +++ b/tests/test_circuits/basic_circuits.py @@ -42,7 +42,7 @@ def unroll(): circ = QuantumCircuit(3) circ.ccx(0, 1, 2) circ.crz(theta=0.1, control_qubit=0, target_qubit=1) - circ.id(0) + circ.id(2) return circ.decompose()