From 1a375dfbeeb9640a2d9782498e0fa5076f768ef2 Mon Sep 17 00:00:00 2001 From: Luciano Bello Date: Mon, 16 Oct 2023 16:52:23 +0200 Subject: [PATCH] deepcopy --- .../transpiler/passes/layout/noise_adaptive_layout.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/qiskit/transpiler/passes/layout/noise_adaptive_layout.py b/qiskit/transpiler/passes/layout/noise_adaptive_layout.py index 9bfe3a7edada..2748e7522ce6 100644 --- a/qiskit/transpiler/passes/layout/noise_adaptive_layout.py +++ b/qiskit/transpiler/passes/layout/noise_adaptive_layout.py @@ -13,7 +13,7 @@ """Choose a noise-adaptive Layout based on current calibration data for the backend.""" import math - +from copy import deepcopy import rustworkx as rx from qiskit.transpiler.layout import Layout @@ -73,21 +73,20 @@ def __init__(self, backend_prop, coupling_map=None): self.backend_prop = target_to_backend_properties(self.target) else: self.target = None - self.backend_prop = backend_prop if coupling_map: # A backend might have more properties than qubits/gates in the configuration. This is a # problem that the Target path should handle differently (by solving that possible # inconsistency internally). For the non-target path, this is a possible solution. # See https://github.com/Qiskit/qiskit/issues/7677 + backend_prop = deepcopy(backend_prop) edge_set = set(coupling_map.graph.edge_list()) - self.backend_prop.gates = filter( + backend_prop.gates = filter( lambda ginfo: tuple(ginfo.qubits) in edge_set, backend_prop.gates, ) - self.backend_prop.qubits = backend_prop.qubits[ - : 1 + max(coupling_map.physical_qubits) - ] + backend_prop.qubits = backend_prop.qubits[: 1 + max(coupling_map.physical_qubits)] + self.backend_prop = backend_prop self.swap_graph = rx.PyDiGraph() self.cx_reliability = {}