From dfe0cc53de8595ec0941c1b5ed8d8ffe5e2c9edf Mon Sep 17 00:00:00 2001 From: chensgit169 Date: Sun, 28 Jan 2024 20:40:35 +0800 Subject: [PATCH] fix: fix uot-of-date of layered_circuit due to pos as list --- quafu/circuits/quantum_circuit.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/quafu/circuits/quantum_circuit.py b/quafu/circuits/quantum_circuit.py index 684e3cb..075e447 100644 --- a/quafu/circuits/quantum_circuit.py +++ b/quafu/circuits/quantum_circuit.py @@ -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) @@ -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)