def sample_schedule(self): """Generate a sample schedule that includes the most common elements of pulse schedules.""" gp0 = library.gaussian(duration=20, amp=1.0, sigma=1.0) gp1 = library.gaussian(duration=20, amp=-1.0, sigma=2.0) gs0 = library.gaussian_square(duration=20, amp=-1.0, sigma=2.0, risefall=3) sched = Schedule(name='test_schedule') sched = sched.append(gp0(DriveChannel(0))) sched = sched.insert(0, Play(library.Constant(duration=60, amp=0.2 + 0.4j), ControlChannel(0))) sched = sched.insert(60, ShiftPhase(-1.57, DriveChannel(0))) sched = sched.insert(60, SetFrequency(8.0, DriveChannel(0))) sched = sched.insert(60, SetPhase(3.14, DriveChannel(0))) sched = sched.insert(70, ShiftFrequency(4.0e6, DriveChannel(0))) sched = sched.insert(30, Play(gp1, DriveChannel(1))) sched = sched.insert(60, Play(gp0, ControlChannel(0))) sched = sched.insert(60, Play(gs0, MeasureChannel(0))) sched = sched.insert(90, ShiftPhase(1.57, DriveChannel(0))) sched = sched.insert(90, Acquire(10, AcquireChannel(1), MemorySlot(1), RegisterSlot(1))) sched = sched.append(Delay(100, DriveChannel(0))) sched = sched + sched sched |= Snapshot("snapshot_1", "snap_type") << 60 sched |= Snapshot("snapshot_2", "snap_type") << 120 return sched
def test_schedule_drawer_show_framechange(self): filename = self._get_resource_path('current_show_framechange_ref.png') gp0 = library.gaussian(duration=20, amp=1.0, sigma=1.0) sched = Schedule(name='test_schedule') sched = sched.append(Play(gp0, DriveChannel(0))) sched = sched.insert(60, ShiftPhase(-1.57, DriveChannel(0))) sched = sched.insert(30, ShiftPhase(-1.50, DriveChannel(1))) sched = sched.insert(70, ShiftPhase(1.50, DriveChannel(1))) pulse_drawer(sched, filename=filename, show_framechange_channels=False) self.assertImagesAreEqual(filename, self.schedule_show_framechange_ref) os.remove(filename)
def test_frame_change(self): """Test converted qobj from ShiftPhase.""" converter = InstructionToQobjConverter(PulseQobjInstruction, meas_level=2) valid_qobj = PulseQobjInstruction(name='fc', ch='d0', t0=0, phase=0.1) instruction = ShiftPhase(0.1, DriveChannel(0)) self.assertEqual(converter(0, instruction), valid_qobj)
def test_frame_change(self): """Test converted qobj from FrameChangeInstruction.""" qobj = PulseQobjInstruction(name='fc', ch='m0', t0=0, phase=0.1) converted_instruction = self.converter(qobj) instruction = ShiftPhase(0.1, MeasureChannel(0)) self.assertEqual(converted_instruction.timeslots, instruction.timeslots) self.assertEqual(converted_instruction.instructions[0][-1], instruction)
def test_frame_change(self): """Test converted qobj from ShiftPhase.""" qobj = PulseQobjInstruction(name="fc", ch="m0", t0=0, phase=0.1) converted_instruction = self.converter(qobj) instruction = ShiftPhase(0.1, MeasureChannel(0)) self.assertEqual(converted_instruction.start_time, 0) self.assertEqual(converted_instruction.duration, 0) self.assertEqual(converted_instruction.instructions[0][-1], instruction)
def test_parameterized_frame_change(self): """Test converted qobj from FrameChangeInstruction.""" instruction = ShiftPhase(4., MeasureChannel(0)) qobj = PulseQobjInstruction(name='fc', ch='m0', t0=10, phase='P1**2') converted_instruction = self.converter(qobj) self.assertIsInstance(converted_instruction, ParameterizedSchedule) evaluated_instruction = converted_instruction.bind_parameters(2.) self.assertEqual(evaluated_instruction.timeslots, instruction.timeslots) self.assertEqual(evaluated_instruction.instructions[0][-1], instruction)
def test_frame_change(self): """Test converted qobj from FrameChangeInstruction.""" converter = InstructionToQobjConverter(PulseQobjInstruction, meas_level=2) with self.assertWarns(DeprecationWarning): command = FrameChange(phase=0.1) with self.assertWarns(DeprecationWarning): instruction = command(DriveChannel(0)) valid_qobj = PulseQobjInstruction(name='fc', ch='d0', t0=0, phase=0.1) self.assertEqual(converter(0, instruction), valid_qobj) instruction = ShiftPhase(0.1, DriveChannel(0)) self.assertEqual(converter(0, instruction), valid_qobj)
def test_parameterized_frame_change(self): """Test converted qobj from ShiftPhase.""" instruction = ShiftPhase(4.0, MeasureChannel(0)) shifted = instruction << 10 qobj = PulseQobjInstruction(name="fc", ch="m0", t0=10, phase="P1*2") converted_instruction = self.converter(qobj) self.assertIsInstance(converted_instruction, Schedule) bind_dict = {converted_instruction.get_parameters("P1")[0]: 2.0} evaluated_instruction = converted_instruction.assign_parameters( bind_dict) self.assertEqual(evaluated_instruction.start_time, shifted.start_time) self.assertEqual(evaluated_instruction.duration, shifted.duration) self.assertEqual(evaluated_instruction.instructions[0][-1], instruction)