def test_alap_with_barriers(self):
    'Test that ALAP respects barriers on new qubits.'
    q = QuantumRegister(2)
    c = ClassicalRegister(2)
    qc = QuantumCircuit(q, c)
    qc.u2(0, 0, q[0])
    qc.barrier(q[0], q[1])
    qc.u2(0, 0, q[1])
    sched = schedule(qc, self.backend, method='alap')
    expected = Schedule(self.cmd_def.get('u2', [0], 0, 0), (28, self.cmd_def.get('u2', [1], 0, 0)))
    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 that ALAP respects barriers on new qubits.
def test_alap_with_barriers(self):
    
    q = QuantumRegister(2)
    c = ClassicalRegister(2)
    qc = QuantumCircuit(q, c)
    qc.u2(0, 0, q[0])
    qc.barrier(q[0], q[1])
    qc.u2(0, 0, q[1])
    sched = schedule(qc, self.backend, method='alap')
    expected = Schedule(self.cmd_def.get('u2', [0], 0, 0), (28, self.cmd_def.get('u2', [1], 0, 0)))
    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)