def test_truncate_acquisition(self): sched = Schedule(name='test_schedule') sched = sched.insert( 0, Acquire(30, AcquireChannel(1), MemorySlot(1), RegisterSlot(1))) # Check ValueError is not thrown pulse_drawer(sched, plot_range=(0, 15))
def test_unmergeable_collections(self): """Test if return false for unmergeable collections. """ col1 = TimeslotCollection(Timeslot(Interval(1, 3), AcquireChannel(0))) col2 = TimeslotCollection(Timeslot(Interval(2, 4), AcquireChannel(0))) self.assertEqual(False, col1.is_mergeable_with(col2))
def test_default(self): """Test valid time-slot creation without error. """ slot = Timeslot(Interval(1, 3), AcquireChannel(0)) self.assertEqual(Interval(1, 3), slot.interval) self.assertEqual(AcquireChannel(0), slot.channel)
def my_test_make_schedule(acquire: int, memoryslot: int, shift: int): op = Acquire(acquire) sched1 = op(AcquireChannel(0), MemorySlot(memoryslot)) sched2 = op(AcquireChannel(1), MemorySlot(memoryslot)).shift(shift) return Schedule(sched1, sched2)
def test_multiple_channels_out_of_order(self): """Test that schedule with multiple channels equal when out of order.""" instructions = [(0, FrameChange(0)(DriveChannel(1))), (1, Acquire(10)(AcquireChannel(0), MemorySlot(1)))] self.assertEqual(Schedule(*instructions), Schedule(*reversed(instructions)))
def test_shift(self): """Test shifting of Timeslot.""" slot_1 = Timeslot(Interval(1, 3), AcquireChannel(0)) slot_2 = Timeslot(Interval(1 + 5, 3 + 5), AcquireChannel(0)) shifted_slot = slot_1.shift(+5) self.assertTrue(slot_2 == shifted_slot)
def test_representation_of_timeslot_object(self): """Test representation of Timeslot object.""" slot = Timeslot(Interval(1, 5), AcquireChannel(0)) self.assertEqual(repr(slot), 'Timeslot(AcquireChannel(0), (1, 5))')
def test_fail_to_create_with_invalid_channel(self): """Test if a LoConfig cannot be created with invalid channel. """ channel = AcquireChannel(0) with self.assertRaises(PulseError): LoConfig({channel: 1.0})
def test_can_create_with_valid_timeslots(self): """Test valid time-slot collection creation without error. """ slots = [Timeslot(Interval(1, 3), AcquireChannel(0)), Timeslot(Interval(3, 5), AcquireChannel(0))] TimeslotCollection(slots)
def test_shifted(self): """Test if `shifted` shifts the collection for specified time. """ actual = TimeslotCollection([Timeslot(Interval(1, 3), AcquireChannel(0))]).shifted(10) expected = TimeslotCollection([Timeslot(Interval(11, 13), AcquireChannel(0))]) self.assertEqual(expected, actual)
def setUp(self): self.device = DeviceSpecification(qubits=[ Qubit(0, DriveChannel(0), MeasureChannel(0), AcquireChannel(0)) ], registers=[RegisterSlot(0)], mem_slots=[MemorySlot(0)])
def test_default(self): """Test default acquire channel.""" acquire_channel = AcquireChannel(123) self.assertEqual(acquire_channel.index, 123) self.assertEqual(acquire_channel.name, "a123")