Skip to content

Commit

Permalink
♻️ remove workarounds for old qiskit versions
Browse files Browse the repository at this point in the history
Signed-off-by: burgholzer <burgholzer@me.com>
  • Loading branch information
burgholzer committed Apr 20, 2024
1 parent 4de63b9 commit a4ad814
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/mqt/core/plugins/qiskit.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ def _add_two_target_operation(


def _import_layouts(qc: QuantumComputation, circ: QuantumCircuit) -> None:
# qiskit-terra 0.24.0 added a (public) `layout` attribute
layout = circ.layout if hasattr(circ, "layout") else circ._layout # noqa: SLF001

layout = circ.layout
initial_layout = layout.initial_layout

# The following creates a map of virtual qubits in the layout to an integer index.
Expand All @@ -386,13 +384,9 @@ def _import_layouts(qc: QuantumComputation, circ: QuantumCircuit) -> None:
for device_qubit, circuit_qubit in initial_layout.get_physical_bits().items():
idx = qubit_to_idx[circuit_qubit]
qc.initial_layout[device_qubit] = idx
qc.output_permutation[device_qubit] = idx

if not hasattr(layout, "final_layout"):
return

final_layout = layout.final_layout
if final_layout is None:
if layout.final_layout is None:
qc.output_permutation = qc.initial_layout
return

# final_index_layout creates a list of final positions for input circuit qubits
Expand Down

0 comments on commit a4ad814

Please sign in to comment.