Skip to content

Commit

Permalink
rewrite CircuitInstrution as iterable (Qiskit#2198)
Browse files Browse the repository at this point in the history
Co-authored-by: Jun Doi <[email protected]>
  • Loading branch information
t-imamichi and doichanj authored Aug 9, 2024
1 parent b170971 commit ad7b86f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions qiskit_aer/backends/aer_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def _inline_initialize(self, circ, optype):
if isinstance(optype, set) and Initialize not in optype:
return circ

for inst, _, _ in circ.data:
for datum in circ.data:
inst = datum.operation
if isinstance(inst, Initialize) and (
(not isinstance(inst.params[0], complex)) or (len(inst.params) == 1)
):
Expand All @@ -133,7 +134,8 @@ def _inline_initialize(self, circ, optype):

new_circ = circ.copy()
new_circ.data = []
for inst, qargs, cargs in circ.data:
for datum in circ.data:
inst, qargs, cargs = datum.operation, datum.qubits, datum.clbits
if isinstance(inst, Initialize) and (
(not isinstance(inst.params[0], complex)) or (len(inst.params) == 1)
):
Expand Down
3 changes: 2 additions & 1 deletion qiskit_aer/backends/aerbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,8 @@ def _assemble_noise_model(self, circuits, optypes, **run_options):
):
updated_circ = False
new_data = []
for inst, qargs, cargs in circ.data:
for datum in circ.data:
inst, qargs, cargs = datum.operation, datum.qubits, datum.clbits
if isinstance(inst, QuantumChannelInstruction):
updated_circ = True
if not updated_noise:
Expand Down

0 comments on commit ad7b86f

Please sign in to comment.