Skip to content

Commit

Permalink
Merge pull request #228 from BQSKit/update-qiskit-tests
Browse files Browse the repository at this point in the history
Updated .qasm() to qasm2.dumps
  • Loading branch information
edyounis authored Feb 28, 2024
2 parents 8e7aae5 + b331038 commit 73ddab3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion bqskit/ext/qiskit/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
if TYPE_CHECKING:
from qiskit import QuantumCircuit

from qiskit import qasm2
from bqskit.ir.circuit import Circuit
from bqskit.ir.lang.qasm2 import OPENQASM2Language


def qiskit_to_bqskit(qc: QuantumCircuit) -> Circuit:
"""Convert Qiskit's QuantumCircuit `qc` to a BQSKit Circuit."""
circuit = OPENQASM2Language().decode(qc.qasm())
circuit = OPENQASM2Language().decode(qasm2.dumps(qc))
# circuit.renumber_qudits(list(reversed(range(circuit.num_qudits))))
return circuit
# TODO: support gates not captured by qasm
Expand Down
16 changes: 8 additions & 8 deletions tests/ext/test_qiskit.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ def bqskit_circuit(self) -> Circuit:
@pytest.fixture
def qiskit_circuit(self) -> QuantumCircuit:
circuit = QuantumCircuit(3)
circuit.cnot(0, 1)
circuit.cx(0, 1)
circuit.u(1, 2, 3, 0)
circuit.u(1, 2, 3, 1)
circuit.u(1, 2, 3, 2)
circuit.cnot(0, 1)
circuit.cnot(0, 2)
circuit.cnot(0, 2)
circuit.cx(0, 1)
circuit.cx(0, 2)
circuit.cx(0, 2)
circuit.u(1, 2.4, 3, 0)
circuit.u(1, 2.2, 3, 1)
circuit.u(1, 2.1, 3, 2)
circuit.u(1, 2.1, 3, 2)
circuit.cnot(0, 2)
circuit.cnot(0, 2)
circuit.cnot(0, 1)
circuit.cnot(0, 2)
circuit.cx(0, 2)
circuit.cx(0, 2)
circuit.cx(0, 1)
circuit.cx(0, 2)
circuit.u(1, 2.4, 3, 0)
circuit.u(1, 2.2, 3, 1)
circuit.u(1, 2.1, 3, 2)
Expand Down

0 comments on commit 73ddab3

Please sign in to comment.