def test_alap_pass(self):
    'Test ALAP scheduling.'
    q = QuantumRegister(2)
    c = ClassicalRegister(2)
    qc = QuantumCircuit(q, c)
    qc.u2(3.14, 1.57, q[0])
    qc.u2(0.5, 0.25, q[1])
    qc.barrier(q[1])
    qc.u2(0.5, 0.25, q[1])
    qc.barrier(q[0], q[1])
    qc.cx(q[0], q[1])
    qc.measure(q, c)
    sched = schedule(qc, self.backend)
    expected = Schedule((28, self.cmd_def.get('u2', [0], 3.14, 1.57)), self.cmd_def.get('u2', [1], 0.5, 0.25), (28, self.cmd_def.get('u2', [1], 0.5, 0.25)), (56, self.cmd_def.get('cx', [0, 1])), (78, self.cmd_def.get('measure', [0, 1])))
    for (actual, expected) in zip(sched.instructions, expected.instructions):
        self.assertEqual(actual[0], expected[0])
        self.assertEqual(actual[1].command, expected[1].command)
        self.assertEqual(actual[1].channels, expected[1].channels)
Test ALAP scheduling.
def test_alap_pass(self):
    
    q = QuantumRegister(2)
    c = ClassicalRegister(2)
    qc = QuantumCircuit(q, c)
    qc.u2(3.14, 1.57, q[0])
    qc.u2(0.5, 0.25, q[1])
    qc.barrier(q[1])
    qc.u2(0.5, 0.25, q[1])
    qc.barrier(q[0], q[1])
    qc.cx(q[0], q[1])
    qc.measure(q, c)
    sched = schedule(qc, self.backend)
    expected = Schedule((28, self.cmd_def.get('u2', [0], 3.14, 1.57)), self.cmd_def.get('u2', [1], 0.5, 0.25), (28, self.cmd_def.get('u2', [1], 0.5, 0.25)), (56, self.cmd_def.get('cx', [0, 1])), (78, self.cmd_def.get('measure', [0, 1])))
    for (actual, expected) in zip(sched.instructions, expected.instructions):
        self.assertEqual(actual[0], expected[0])
        self.assertEqual(actual[1].command, expected[1].command)
        self.assertEqual(actual[1].channels, expected[1].channels)