Skip to content

Commit

Permalink
Fix bug of flatten_and_balance for leaves
Browse files Browse the repository at this point in the history
  • Loading branch information
terrorfisch committed Jun 18, 2018
1 parent b138ac7 commit f1f723a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion qctoolkit/hardware/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ def repetition_count(self, val) -> None:
self._repetition_count = new_repetition

def unroll(self) -> None:
if self.is_leaf():
raise RuntimeError('Leaves cannot be unrolled')
for i, e in enumerate(self.parent):
if id(e) == id(self):
self.parent[i:i+1] = (child.copy_tree_structure(new_parent=self.parent)
Expand Down Expand Up @@ -253,9 +255,11 @@ def flatten_and_balance(self, depth: int) -> None:
sub_program[:] = sub_sub_program[:]
sub_program.waveform = sub_sub_program.waveform

else:
elif not sub_program.is_leaf():
sub_program.unroll()

else:
i += 1

class ChannelSplit(Exception):
def __init__(self, channel_sets):
Expand Down

0 comments on commit f1f723a

Please sign in to comment.