Skip to content

Commit

Permalink
Fix scheduler test to preserve labels in branches.
Browse files Browse the repository at this point in the history
  • Loading branch information
blakejohnson committed May 24, 2017
1 parent 942e715 commit 05ef86c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/test_Scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,23 @@ def test_controlflow(self):
# in tensor products, i.e. we want qif(..) * qif(...) to be valid
q1, q2, q3, q4 = self.q1, self.q2, self.q3, self.q4

cond_seq = qif(1, [Y(q1),Y(q2),X90(q1)], [Z(q1),Z(q2),X90(q1)])
seq = [X(q1),X(q2),
CNOT(q1,q2)] + \
qif(1, [Y(q1),Y(q2),X90(q1)], [Z(q1),Z(q2),X90(q1)]) + \
cond_seq + \
[Y90(q1),Y90(q2)]

result = schedule(seq)

# construct the scheduled conditional from the original to preserve labels
cond_seq_scheduled = cond_seq[:2] + \
[Z(q1) * Z(q2), X90(q1)] + \
cond_seq[5:7] + \
[Y(q1) * Y(q2), X90(q1)] + \
cond_seq[-1:]
assert(result == [X(q1) * X(q2),
CNOT(q1, q2)] + \
qif(1, [Y(q1)*Y(q2), X90(q1)], [Z(q1)*Z(q2), X90(q1)]) + \
cond_seq_scheduled + \
[Y90(q1) * Y90(q2)])

# test that "global" control flow injects barriers
Expand All @@ -97,5 +105,5 @@ def test_controlflow(self):

result = schedule(seq)
assert(result == [X(q1)] + \
qif(1, [Y(q1)*Y(q2), X90(q1)], [Z(q1)*Z(q2), X90(q1)]) + \
cond_seq_scheduled + \
[Y90(q1) * Y90(q2)])

0 comments on commit 05ef86c

Please sign in to comment.