def test_barriers_in_middle(self):
    'As a follow on to `test_can_add_gates_into_free_space`, similar issues\n        arose for barriers, specifically.\n        '
    qr = QuantumRegister(2)
    qc = QuantumCircuit(qr)
    for i in range(2):
        qc.u2(0, 0, [qr[i]])
        qc.barrier(qr[i])
        qc.u1(3.14, [qr[i]])
        qc.barrier(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)
As a follow on to `test_can_add_gates_into_free_space`, similar issues
arose for barriers, specifically.
def test_barriers_in_middle(self):
    'As a follow on to `test_can_add_gates_into_free_space`, similar issues\n        arose for barriers, specifically.\n        '
    qr = QuantumRegister(2)
    qc = QuantumCircuit(qr)
    for i in range(2):
        qc.u2(0, 0, [qr[i]])
        qc.barrier(qr[i])
        qc.u1(3.14, [qr[i]])
        qc.barrier(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)