From d51b456c6e56d9c465012f6c0da3ba67200821b9 Mon Sep 17 00:00:00 2001 From: Toshinari Itoko Date: Wed, 29 Nov 2023 22:36:27 +0900 Subject: [PATCH] Use Target more safely --- .../library/randomized_benchmarking/standard_rb.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/qiskit_experiments/library/randomized_benchmarking/standard_rb.py b/qiskit_experiments/library/randomized_benchmarking/standard_rb.py index 2d629c9602..86ec87f836 100644 --- a/qiskit_experiments/library/randomized_benchmarking/standard_rb.py +++ b/qiskit_experiments/library/randomized_benchmarking/standard_rb.py @@ -23,7 +23,7 @@ from numpy.random import Generator, default_rng from numpy.random.bit_generator import BitGenerator, SeedSequence -from qiskit.circuit import CircuitInstruction, QuantumCircuit, Instruction, Barrier +from qiskit.circuit import CircuitInstruction, QuantumCircuit, Instruction, Barrier, Gate from qiskit.exceptions import QiskitError from qiskit.providers import BackendV2Converter from qiskit.providers.backend import Backend, BackendV1, BackendV2 @@ -236,11 +236,10 @@ def _get_synthesis_options(self) -> Dict[str, Optional[Any]]: basis_gates = basis_gates if basis_gates else self.backend.target.operation_names coupling_map = coupling_map if coupling_map else None elif isinstance(self.backend, BackendV2): - backend_basis_gates = [ - op.name for op in self.backend.target.operations if op.num_qubits != 2 - ] + gate_ops = [op for op in self.backend.target.operations if isinstance(op, Gate)] + backend_basis_gates = [op.name for op in gate_ops if op.num_qubits != 2] backend_cmap = None - for op in self.backend.target.operations: + for op in gate_ops: if op.num_qubits != 2: continue cmap = self.backend.target.build_coupling_map(op.name)