def test_alap_resource_respecting(self):
    "Test that the ALAP pass properly respects busy resources when backwards scheduling.\n        For instance, a CX on 0 and 1 followed by an X on only 1 must respect both qubits'\n        timeline."
    q = QuantumRegister(2)
    c = ClassicalRegister(2)
    qc = QuantumCircuit(q, c)
    qc.cx(q[0], q[1])
    qc.u2(0.5, 0.25, q[1])
    sched = schedule(qc, self.backend, method='as_late_as_possible')
    insts = sched.instructions
    self.assertEqual(insts[0][0], 0)
    self.assertEqual(insts[4][0], 22)
    qc = QuantumCircuit(q, c)
    qc.cx(q[0], q[1])
    qc.u2(0.5, 0.25, q[1])
    qc.measure(q, c)
    sched = schedule(qc, self.backend, method='as_late_as_possible')
    self.assertEqual(sched.instructions[(- 1)][0], 50)
Test that the ALAP pass properly respects busy resources when backwards scheduling.
For instance, a CX on 0 and 1 followed by an X on only 1 must respect both qubits'
timeline.
def test_alap_resource_respecting(self):
    "Test that the ALAP pass properly respects busy resources when backwards scheduling.\n        For instance, a CX on 0 and 1 followed by an X on only 1 must respect both qubits'\n        timeline."
    q = QuantumRegister(2)
    c = ClassicalRegister(2)
    qc = QuantumCircuit(q, c)
    qc.cx(q[0], q[1])
    qc.u2(0.5, 0.25, q[1])
    sched = schedule(qc, self.backend, method='as_late_as_possible')
    insts = sched.instructions
    self.assertEqual(insts[0][0], 0)
    self.assertEqual(insts[4][0], 22)
    qc = QuantumCircuit(q, c)
    qc.cx(q[0], q[1])
    qc.u2(0.5, 0.25, q[1])
    qc.measure(q, c)
    sched = schedule(qc, self.backend, method='as_late_as_possible')
    self.assertEqual(sched.instructions[(- 1)][0], 50)