def test_func(dur: int): sched = Schedule() sched += Play(library.constant(int(dur), amp), DriveChannel(0)) return sched
def test_func(dur: ParameterExpression, t_val: int): dur_bound = dur.bind({t_param: t_val}) sched = Schedule() sched += Play(library.constant(int(float(dur_bound)), amp), DriveChannel(0)) return sched
def test_insert_float_time_raises(self): """Test that a floating time will raise an error with insert.""" sched = Schedule() sched += Delay(1, DriveChannel(0)) with self.assertRaises(PulseError): sched.insert(10.1, sched)
def test_shift_unshift(self): """Test shift and then unshifting of schedule""" reference_sched = Schedule() reference_sched += Delay(10, DriveChannel(0)) shifted_sched = reference_sched.shift(10).shift(-10) self.assertEqual(shifted_sched, reference_sched)
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_func(x): sched = Schedule() sched += pulse_lib.constant(int(x), amp_test)(DriveChannel(0)) return sched
def test_fail_to_create_with_out_of_range_user_lo(self): """Test if a LoConfig cannot be created with invalid user_los. """ channel = DriveChannel(0) with self.assertRaises(PulseError): LoConfig({channel: 3.3}, {channel: (1.0, 2.0)})
def test_same_time_equal(self): """Test equal if instruction at same time.""" self.assertEqual(Schedule((0, FrameChange(0)(DriveChannel(1)))), Schedule((0, FrameChange(0)(DriveChannel(1)))))
def setUp(self): self.device = DeviceSpecification(qubits=[ Qubit(0, DriveChannel(0), MeasureChannel(0), AcquireChannel(0)) ], registers=[RegisterSlot(0)], mem_slots=[MemorySlot(0)])
def test_padding_less_than_sched_duration(self): """Test that the until arg is respected even for less than the input schedule duration.""" delay = 10 sched = Delay(delay, DriveChannel(0)) + Delay(delay, DriveChannel(0)).shift(20) ref_sched = sched | pulse.Delay(5, DriveChannel(0)).shift(10) self.assertEqual(transforms.pad(sched, until=15), ref_sched)
def callable_schedule(par_b, par_a): sched = Schedule() sched.insert(10, Play(Constant(10, par_b), DriveChannel(0)), inplace=True) sched.insert(20, Play(Constant(10, par_a), DriveChannel(0)), inplace=True) return sched
def test_numpy_integer_input(self): """Test that mixed integer duration types can build a schedule (#5754).""" sched = Schedule() sched += Delay(np.int32(25), DriveChannel(0)) sched += Play(Constant(duration=30, amp=0.1), DriveChannel(0)) self.assertEqual(sched.duration, 55)
def test_default(self): """Test default drive channel.""" drive_channel = DriveChannel(123) self.assertEqual(drive_channel.index, 123) self.assertEqual(drive_channel.name, "d123")
def sample_instruction(self): """Generate a sample instruction.""" return self.sample_pulse()(DriveChannel(0))
def test_drive_instruction(self): """Test converted qobj from PulseInstruction.""" instruction = Play(self.linear, DriveChannel(0)) qobj = PulseQobjInstruction(name='linear', ch='d0', t0=10) converted_instruction = self.converter(qobj) self.assertEqual(converted_instruction.instructions[0][-1], instruction)
def test_different_channels(self): """Test equality is False if different channels.""" self.assertNotEqual(Schedule(FrameChange(0)(DriveChannel(0))), Schedule(FrameChange(0)(DriveChannel(1))))
def test_func(x): sched = Schedule() sched += Play(library.constant(int(x), amp_test), DriveChannel(0)) return sched
def test_different_time_not_equal(self): """Test that not equal if instruction at different time.""" self.assertNotEqual(Schedule((0, FrameChange(0)(DriveChannel(1)))), Schedule((1, FrameChange(0)(DriveChannel(1)))))
def test_negative_time_raises(self): """Test that a negative time will raise an error.""" sched = Schedule() sched += Delay(1, DriveChannel(0)) with self.assertRaises(PulseError): sched.shift(-10)
def test_different_name_equal(self): """Test that names are ignored when checking equality.""" self.assertEqual(Schedule((0, FrameChange(0, name='fc1')(DriveChannel(1))), name='s1'), Schedule((0, FrameChange(0, name='fc2')(DriveChannel(1))), name='s2'))
def test_overlapping_pulses(self): """Test that an error is still raised when overlapping instructions are assigned.""" schedule = pulse.Schedule() schedule |= pulse.Play(pulse.Waveform([1, 1, 1, 1]), DriveChannel(self.qubit)) with self.assertRaises(PulseError): schedule |= pulse.Play(pulse.Waveform([0.5, 0.5, 0.5, 0.5]), DriveChannel(self.qubit))