Skip to content

Commit

Permalink
Fix legacy accesses of CircuitInstruction in tests (#2191)
Browse files Browse the repository at this point in the history
This is a follow-up to #2179, with similar fixes in two tests.
  • Loading branch information
garrison authored Jul 12, 2024
1 parent e56cbbb commit 0388bca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 7 additions & 6 deletions test/terra/backends/aer_simulator/test_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
Expand Down
13 changes: 7 additions & 6 deletions test/terra/backends/aer_simulator/test_shot_branching.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
Expand Down

0 comments on commit 0388bca

Please sign in to comment.