Skip to content

Commit

Permalink
fix: fix uot-of-date of layered_circuit due to pos as list
Browse files Browse the repository at this point in the history
  • Loading branch information
chensgit169 committed Jan 28, 2024
1 parent 9d9070b commit dfe0cc5
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions quafu/circuits/quantum_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,11 @@ def layered_circuit(self) -> np.ndarray:
gateQlist = [[] for i in range(num)]
used_qubits = []
for gate in gatelist:
if (
isinstance(gate, SingleQubitGate)
or isinstance(gate, Delay)
or isinstance(gate, QuantumPulse)
):
gateQlist[gate.pos].append(gate)
if len(gate.pos) == 1:
p = gate.pos[0]
gateQlist[p].append(gate)
if gate.pos not in used_qubits:
used_qubits.append(gate.pos)

elif (
isinstance(gate, Barrier)
or isinstance(gate, MultiQubitGate)
Expand All @@ -202,7 +198,7 @@ def layered_circuit(self) -> np.ndarray:
for j in range(pos1 + 1, pos2 + 1):
gateQlist[j].append(None)

if isinstance(gate, MultiQubitGate) or isinstance(gate, XYResonance):
if isinstance(gate, (MultiQubitGate, XYResonance)):
for pos in gate.pos:
if pos not in used_qubits:
used_qubits.append(pos)
Expand Down

0 comments on commit dfe0cc5

Please sign in to comment.