def test_creation_from_backend_with_zero_u_channels(self): """Test creation of device specification from backend with u_channels == 0. """ class DummyBackend: """Dummy backend""" def configuration(self): # pylint: disable=missing-docstring class DummyConfig: @property def n_qubits(self): return 2 @property def n_registers(self): return 2 @property def n_uchannels(self): return 0 @property def defaults(self): return { 'qubit_freq_est': [1.2, 3.4], 'meas_freq_est': [1.2, 3.4] } return DummyConfig() device = DeviceSpecification.create_from(DummyBackend()) self.assertEqual(device.q[0].drive, DriveChannel(0, 1.2)) with self.assertRaises(PulseError): _ = device.q[0].control
def test_creation_from_backend_with_zero_u_channels(self): """Test creation of device specification from backend with u_channels == 0. """ backend = FakeOpenPulse2Q() device = DeviceSpecification.create_from(backend) self.assertEqual(device.q[0].drive, DriveChannel(0))
def setUp(self): self.device = DeviceSpecification(qubits=[ Qubit(0, drive_channels=[DriveChannel(0, 1.2)], acquire_channels=[AcquireChannel(0)]) ], registers=[RegisterSlot(0)], mem_slots=[MemorySlot(0)])
def setUp(self): self.device = DeviceSpecification( qubits=[ Qubit(0, DriveChannel(0), MeasureChannel(0), AcquireChannel(0)) ], registers=[ RegisterSlot(0) ], mem_slots=[ MemorySlot(0) ] )
def test_creation_from_backend_with_zero_u_channels(self): """Test creation of device specification from backend with u_channels == 0. """ backend = FakeOpenPulse2Q() # overwrite n_uchannel backend._configuration.n_uchannels = 0 device = DeviceSpecification.create_from(backend) self.assertEqual(device.q[0].drive, DriveChannel(0, 4.9, (4.5, 5.5))) with self.assertRaises(PulseError): device.q[0].control()
def setUp(self): qubits = [ Qubit(0, drive_channels=[DriveChannel(0, 1.2)], control_channels=[ControlChannel(0)]), Qubit(1, drive_channels=[DriveChannel(1, 3.4)], acquire_channels=[AcquireChannel(1)]) ] registers = [RegisterSlot(i) for i in range(2)] mem_slots = [MemorySlot(i) for i in range(2)] self.two_qubit_device = DeviceSpecification(qubits, registers, mem_slots)
def setUp(self): @functional_pulse def linear(duration, slope, intercept): x = np.linspace(0, duration - 1, duration) return slope * x + intercept self.linear = linear qubits = [Qubit(0, DriveChannel(0), AcquireChannel(0), MeasureChannel(0), control_channels=[ControlChannel(0)]), Qubit(1, DriveChannel(1), MeasureChannel(0), AcquireChannel(1))] registers = [RegisterSlot(i) for i in range(2)] mem_slots = [MemorySlot(i) for i in range(2)] self.two_qubit_device = DeviceSpecification(qubits, registers, mem_slots)
def setUp(self): self.linear = SamplePulse(np.arange(0, 0.01), name='linear') self.pulse_library = [ PulseLibraryItem(name=self.linear.name, samples=self.linear.samples.tolist()) ] self.converter = QobjToInstructionConverter(self.pulse_library, buffer=0) self.device = DeviceSpecification(qubits=[ Qubit(0, DriveChannel(0), MeasureChannel(0), AcquireChannel(0)) ], registers=[RegisterSlot(0)], mem_slots=[MemorySlot(0)])
def setUp(self): super().setUp() qubits = [ Qubit(0, DriveChannel(0), AcquireChannel(0), MeasureChannel(0), control_channels=[ControlChannel(0)]), Qubit(1, DriveChannel(1), MeasureChannel(0), AcquireChannel(1)) ] registers = [RegisterSlot(i) for i in range(2)] mem_slots = [MemorySlot(i) for i in range(2)] self.two_qubit_device = DeviceSpecification(qubits, registers, mem_slots)
def test_default(self): """Test default device specification. """ qubits = [ Qubit(0, DriveChannel(0), MeasureChannel(0), AcquireChannel(0)), Qubit(1, DriveChannel(1), MeasureChannel(1), AcquireChannel(1)) ] registers = [RegisterSlot(i) for i in range(2)] mem_slots = [MemorySlot(i) for i in range(2)] spec = DeviceSpecification(qubits, registers, mem_slots) self.assertEqual(spec.q[0].drive, DriveChannel(0)) self.assertEqual(spec.q[1].acquire, AcquireChannel(1)) self.assertEqual(spec.mem[0], MemorySlot(0)) self.assertEqual(spec.c[1], RegisterSlot(1))
def setUp(self): self.schedule = Schedule() self.qubits = [ Qubit(0, drive_channel=DriveChannel(0), control_channels=[ControlChannel(0)], measure_channel=MeasureChannel(0), acquire_channel=AcquireChannel(0)), Qubit(1, drive_channel=DriveChannel(1), acquire_channel=AcquireChannel(1), measure_channel=MeasureChannel(1)) ] self.registers = [RegisterSlot(i) for i in range(2)] self.mem_slots = [MemorySlot(i) for i in range(2)] self.device = DeviceSpecification(self.qubits, self.registers, self.mem_slots)