Skip to content

Commit 92ac35d

Browse files
AriJordanTakishima
authored andcommitted
fix circ drawer when depth == 1
1 parent 22d664f commit 92ac35d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

projectq/backends/_circuits/_plot.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,14 @@ def calculate_gate_grid(axes, qubit_lines, plot_params):
222222
]
223223

224224
gate_grid = np.array([0] * (depth + 1), dtype=float)
225-
226-
gate_grid[0] = plot_params['labels_margin'] + (width_list[0]) * 0.5
227-
for idx in range(1, depth):
228-
gate_grid[idx] = gate_grid[idx - 1] + column_spacing + (
229-
width_list[idx] + width_list[idx - 1]) * 0.5
230-
gate_grid[-1] = gate_grid[-2] + column_spacing + width_list[-1] * 0.5
225+
226+
gate_grid[0] = plot_params['labels_margin']
227+
if depth > 0:
228+
gate_grid[0] += width_list[0] * 0.5
229+
for idx in range(1, depth):
230+
gate_grid[idx] = gate_grid[idx - 1] + column_spacing + (
231+
width_list[idx] + width_list[idx - 1]) * 0.5
232+
gate_grid[-1] = gate_grid[-2] + column_spacing + width_list[-1] * 0.5
231233
return gate_grid
232234

233235

0 commit comments

Comments
 (0)