Skip to content

Commit 0f9e89a

Browse files
committed
fix bug qiboteam#1437
1 parent 232c455 commit 0f9e89a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/qibo/ui/mpldrawer.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -553,12 +553,13 @@ def _make_cluster_gates(gates_items):
553553
return cluster_gates
554554

555555

556-
def _process_gates(array_gates):
556+
def _process_gates(array_gates, nqubits):
557557
"""
558558
Transforms the list of gates given by the Qibo circuit into a list of gates with a suitable structre to print on screen with matplotlib.
559559
560560
Args:
561561
array_gates (list): List of gates provided by the Qibo circuit.
562+
nqubits (int): Number of circuit qubits
562563
563564
Returns:
564565
list: List of suitable gates to plot with matplotlib.
@@ -601,7 +602,7 @@ def _process_gates(array_gates):
601602
item += ("q_" + str(qbit),)
602603
gates_plot.append(item)
603604
elif init_label == "ENTANGLEMENTENTROPY":
604-
for qbit in list(range(circuit.nqubits)):
605+
for qbit in list(range(nqubits)):
605606
item = (init_label,)
606607
item += ("q_" + str(qbit),)
607608
gates_plot.append(item)
@@ -718,9 +719,9 @@ def plot_circuit(circuit, scale=0.6, cluster_gates=True, style=None):
718719
fgates = None
719720

720721
if cluster_gates:
721-
fgates = _make_cluster_gates(_process_gates(gate.gates))
722+
fgates = _make_cluster_gates(_process_gates(gate.gates, circuit.nqubits))
722723
else:
723-
fgates = _process_gates(gate.gates)
724+
fgates = _process_gates(gate.gates, circuit.nqubits)
724725

725726
l_gates = len(gate.gates)
726727
equal_qbits = False
@@ -736,7 +737,7 @@ def plot_circuit(circuit, scale=0.6, cluster_gates=True, style=None):
736737
else:
737738
all_gates.append(gate)
738739

739-
gates_plot = _process_gates(all_gates)
740+
gates_plot = _process_gates(all_gates, circuit.nqubits)
740741

741742
if cluster_gates and len(gates_plot) > 0:
742743
gates_cluster = _make_cluster_gates(gates_plot)

0 commit comments

Comments
 (0)