Skip to content

Commit b1f8b82

Browse files
authored
Remove trailing empty ListSweep from merged sweep (#7664)
- when calling merge_single_qubit_gates_to_phxz_symbolized, if remaining symbols is empty, then an empty ListSweep is added to the end of the sweep. - This empty ListSweep confuses parsers, which then interpret this as a sweep of zero length and return an empty list. - This now only adds this ListSweep if there is something to add.
1 parent 23afd92 commit b1f8b82

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

cirq-core/cirq/transformers/merge_single_qubit_gates.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,12 @@ def merge_single_qubit_gates_to_phxz_symbolized(
323323
)
324324

325325
# Step 3, get N sets of parameterizations as new_sweep.
326-
new_sweep = Zip(
327-
_calc_phxz_sweeps(new_circuit, merged_circuits), # phxz sweeps
328-
_sweep_on_symbols(sweep, remaining_symbols), # remaining sweeps
329-
)
326+
if remaining_symbols:
327+
new_sweep: Sweep = Zip(
328+
_calc_phxz_sweeps(new_circuit, merged_circuits), # phxz sweeps
329+
_sweep_on_symbols(sweep, remaining_symbols), # remaining sweeps
330+
)
331+
else:
332+
new_sweep = _calc_phxz_sweeps(new_circuit, merged_circuits)
330333

331334
return align.align_right(new_circuit), new_sweep

0 commit comments

Comments
 (0)