@@ -553,12 +553,13 @@ def _make_cluster_gates(gates_items):
553
553
return cluster_gates
554
554
555
555
556
- def _process_gates (array_gates ):
556
+ def _process_gates (array_gates , nqubits ):
557
557
"""
558
558
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.
559
559
560
560
Args:
561
561
array_gates (list): List of gates provided by the Qibo circuit.
562
+ nqubits (int): Number of circuit qubits
562
563
563
564
Returns:
564
565
list: List of suitable gates to plot with matplotlib.
@@ -601,7 +602,7 @@ def _process_gates(array_gates):
601
602
item += ("q_" + str (qbit ),)
602
603
gates_plot .append (item )
603
604
elif init_label == "ENTANGLEMENTENTROPY" :
604
- for qbit in list (range (circuit . nqubits )):
605
+ for qbit in list (range (nqubits )):
605
606
item = (init_label ,)
606
607
item += ("q_" + str (qbit ),)
607
608
gates_plot .append (item )
@@ -718,9 +719,9 @@ def plot_circuit(circuit, scale=0.6, cluster_gates=True, style=None):
718
719
fgates = None
719
720
720
721
if cluster_gates :
721
- fgates = _make_cluster_gates (_process_gates (gate .gates ))
722
+ fgates = _make_cluster_gates (_process_gates (gate .gates , circuit . nqubits ))
722
723
else :
723
- fgates = _process_gates (gate .gates )
724
+ fgates = _process_gates (gate .gates , circuit . nqubits )
724
725
725
726
l_gates = len (gate .gates )
726
727
equal_qbits = False
@@ -736,7 +737,7 @@ def plot_circuit(circuit, scale=0.6, cluster_gates=True, style=None):
736
737
else :
737
738
all_gates .append (gate )
738
739
739
- gates_plot = _process_gates (all_gates )
740
+ gates_plot = _process_gates (all_gates , circuit . nqubits )
740
741
741
742
if cluster_gates and len (gates_plot ) > 0 :
742
743
gates_cluster = _make_cluster_gates (gates_plot )
0 commit comments