def test_can_add_gates_into_free_space(self):
    'The scheduler does some time bookkeeping to know when qubits are free to be\n        scheduled. Make sure this works for qubits that are used in the future. This was\n        a bug, uncovered by this example:\n\n           q0 =  - - - - |X|\n           q1 = |X| |u2| |X|\n\n        In ALAP scheduling, the next operation on qubit 0 would be added at t=0 rather\n        than immediately before the X gate.\n        '
    qr = QuantumRegister(2)
    qc = QuantumCircuit(qr)
    for i in range(2):
        qc.u2(0, 0, [qr[i]])
        qc.u1(3.14, [qr[i]])
        qc.u2(0, 0, [qr[i]])
    sched = schedule(qc, self.backend, method='alap')
    expected = Schedule(self.cmd_def.get('u2', [0], 0, 0), self.cmd_def.get('u2', [1], 0, 0), (28, self.cmd_def.get('u1', [0], 3.14)), (28, self.cmd_def.get('u1', [1], 3.14)), (28, self.cmd_def.get('u2', [0], 0, 0)), (28, self.cmd_def.get('u2', [1], 0, 0)))
    self.assertEqual(sched.instructions, expected.instructions)
The scheduler does some time bookkeeping to know when qubits are free to be
scheduled. Make sure this works for qubits that are used in the future. This was
a bug, uncovered by this example:

   q0 =  - - - - |X|
   q1 = |X| |u2| |X|

In ALAP scheduling, the next operation on qubit 0 would be added at t=0 rather
than immediately before the X gate.
def test_can_add_gates_into_free_space(self):
    'The scheduler does some time bookkeeping to know when qubits are free to be\n        scheduled. Make sure this works for qubits that are used in the future. This was\n        a bug, uncovered by this example:\n\n           q0 =  - - - - |X|\n           q1 = |X| |u2| |X|\n\n        In ALAP scheduling, the next operation on qubit 0 would be added at t=0 rather\n        than immediately before the X gate.\n        '
    qr = QuantumRegister(2)
    qc = QuantumCircuit(qr)
    for i in range(2):
        qc.u2(0, 0, [qr[i]])
        qc.u1(3.14, [qr[i]])
        qc.u2(0, 0, [qr[i]])
    sched = schedule(qc, self.backend, method='alap')
    expected = Schedule(self.cmd_def.get('u2', [0], 0, 0), self.cmd_def.get('u2', [1], 0, 0), (28, self.cmd_def.get('u1', [0], 3.14)), (28, self.cmd_def.get('u1', [1], 3.14)), (28, self.cmd_def.get('u2', [0], 0, 0)), (28, self.cmd_def.get('u2', [1], 0, 0)))
    self.assertEqual(sched.instructions, expected.instructions)