From 7ef9ca904d2203c13310c0bf076814d2b14b28d4 Mon Sep 17 00:00:00 2001 From: Jim Garrison Date: Wed, 10 Jul 2024 14:46:53 -0400 Subject: [PATCH] Fix legacy accesses of `CircuitInstruction` in tests This is a follow-up to #2179, with similar fixes in two tests. --- test/terra/backends/aer_simulator/test_noise.py | 13 +++++++------ .../backends/aer_simulator/test_shot_branching.py | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/test/terra/backends/aer_simulator/test_noise.py b/test/terra/backends/aer_simulator/test_noise.py index a4f223ae02..c851252e9f 100644 --- a/test/terra/backends/aer_simulator/test_noise.py +++ b/test/terra/backends/aer_simulator/test_noise.py @@ -243,12 +243,13 @@ def _test_kraus_gate_noise_on_QFT(self, **options): # manaully build noise circuit noise_circuit = QuantumCircuit(3) - for inst, qargs, cargs in ideal_circuit.data: - noise_circuit.append(inst, qargs, cargs) - if inst.name == "h": - noise_circuit.append(error1, qargs) - elif inst.name in ["cp", "swap"]: - noise_circuit.append(error2, qargs) + for inst in ideal_circuit.data: + noise_circuit.append(inst) + name = inst.operation.name + if name == "h": + noise_circuit.append(error1, inst.qubits) + elif name in ["cp", "swap"]: + noise_circuit.append(error2, inst.qubits) # compute target counts noise_state = DensityMatrix(noise_circuit) ref_target = {i: shots * p for i, p in noise_state.probabilities_dict().items()} diff --git a/test/terra/backends/aer_simulator/test_shot_branching.py b/test/terra/backends/aer_simulator/test_shot_branching.py index 5b330a4e53..63732b79b6 100644 --- a/test/terra/backends/aer_simulator/test_shot_branching.py +++ b/test/terra/backends/aer_simulator/test_shot_branching.py @@ -494,12 +494,13 @@ def test_shot_branching_kraus_gate_noise_on_QFT(self, method, device): # manaully build noise circuit noise_circuit = QuantumCircuit(3) - for inst, qargs, cargs in ideal_circuit.data: - noise_circuit.append(inst, qargs, cargs) - if inst.name == "h": - noise_circuit.append(error1, qargs) - elif inst.name in ["cp", "swap"]: - noise_circuit.append(error2, qargs) + for inst in ideal_circuit.data: + noise_circuit.append(inst) + name = inst.operation.name + if name == "h": + noise_circuit.append(error1, inst.qubits) + elif name in ["cp", "swap"]: + noise_circuit.append(error2, inst.qubits) # compute target counts noise_state = DensityMatrix(noise_circuit) ref_target = {i: shots * p for i, p in noise_state.probabilities_dict().items()}