def test_barrier_output(self):
        """Test barrier output."""
        bit_event = events.BitEvents(self.qubits[0], self.instructions, 200)

        barriers = list(bit_event.get_barriers())
        ref_list = [
            types.Barrier(t0=120, bits=[self.qubits[0], self.qubits[1]], bit_position=0),
            types.Barrier(t0=200, bits=[self.qubits[0]], bit_position=0)
        ]

        self.assertListEqual(barriers, ref_list)
    def test_bit_link_output(self):
        """Test link output."""
        bit_event = events.BitEvents(self.qubits[0], self.instructions, 250)

        links = list(bit_event.get_gate_links())
        ref_list = [
            types.GateLink(t0=35.0, opname=library.CXGate().name,
                           bits=[self.qubits[0], self.qubits[1]]),
            types.GateLink(t0=250.0, opname=library.Measure().name,
                           bits=[self.qubits[0], self.clbits[0]])
        ]

        self.assertListEqual(links, ref_list)
Exemple #3
0
    def test_gate_output(self):
        """Test gate output."""
        bit_event = events.BitEvents(self.qubits[0], self.instructions, 300)

        gates = list(bit_event.get_gates())
        ref_list = [
            types.ScheduledGate(
                t0=0, operand=library.U1Gate(0), duration=0, bits=[self.qubits[0]], bit_position=0
            ),
            types.ScheduledGate(
                t0=0,
                operand=library.U2Gate(0, 0),
                duration=10,
                bits=[self.qubits[0]],
                bit_position=0,
            ),
            types.ScheduledGate(
                t0=10,
                operand=library.CXGate(),
                duration=50,
                bits=[self.qubits[0], self.qubits[1]],
                bit_position=0,
            ),
            types.ScheduledGate(
                t0=100,
                operand=library.U3Gate(0, 0, 0),
                duration=20,
                bits=[self.qubits[0]],
                bit_position=0,
            ),
            types.ScheduledGate(
                t0=120,
                operand=library.CXGate(),
                duration=50,
                bits=[self.qubits[1], self.qubits[0]],
                bit_position=1,
            ),
            types.ScheduledGate(
                t0=200,
                operand=library.Measure(),
                duration=100,
                bits=[self.qubits[0], self.clbits[0]],
                bit_position=0,
            ),
        ]

        self.assertListEqual(gates, ref_list)