def setUp(self) -> None: """Setup.""" super().setUp() self.qubits = list(qiskit.QuantumRegister(2)) self.clbits = list(qiskit.ClassicalRegister(2)) self.instructions = [ 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.Barrier(2), duration=0, bits=[self.qubits[0], self.qubits[1]], 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.Barrier(1), duration=0, bits=[self.qubits[0]], bit_position=0), types.ScheduledGate(t0=200, operand=library.Measure(), duration=100, bits=[self.qubits[0], self.clbits[0]], bit_position=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)