Exemple #1
0
    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
Exemple #2
0
 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 sample_schedule(self):
        """Generate a sample schedule that includes the most common elements of
           pulse schedules."""
        gp0 = pulse_lib.gaussian(duration=20, amp=1.0, sigma=1.0)
        gp1 = pulse_lib.gaussian(duration=20, amp=-1.0, sigma=2.0)
        gs0 = pulse_lib.gaussian_square(duration=20,
                                        amp=-1.0,
                                        sigma=2.0,
                                        risefall=3)

        fc_pi_2 = FrameChange(phase=1.57)
        acquire = Acquire(10)
        delay = Delay(100)
        sched = Schedule()
        sched = sched.append(gp0(DriveChannel(0)))
        sched = sched.insert(
            0,
            pulse_lib.ConstantPulse(duration=60,
                                    amp=0.2 + 0.4j)(ControlChannel(0)))
        sched = sched.insert(60, FrameChange(phase=-1.57)(DriveChannel(0)))
        sched = sched.insert(60, SetFrequency(8.0, DriveChannel(0)))
        sched = sched.insert(30, gp1(DriveChannel(1)))
        sched = sched.insert(60, gp0(ControlChannel(0)))
        sched = sched.insert(60, gs0(MeasureChannel(0)))
        sched = sched.insert(90, fc_pi_2(DriveChannel(0)))
        sched = sched.insert(
            90, acquire(AcquireChannel(1), MemorySlot(1), RegisterSlot(1)))
        sched = sched.append(delay(DriveChannel(0)))
        sched = sched + sched
        sched |= Snapshot("snapshot_1", "snap_type") << 60
        sched |= Snapshot("snapshot_2", "snap_type") << 120
        return sched
 def test_truncate_acquisition(self):
     sched = Schedule()
     acquire = Acquire(30)
     sched = sched.insert(
         0, acquire(AcquireChannel(1), MemorySlot(1), RegisterSlot(1)))
     # Check ValueError is not thrown
     sched.draw(plot_range=(0, 15))
Exemple #5
0
    def test_acquire(self):
        """Test converted qobj from AcquireInstruction."""
        converter = InstructionToQobjConverter(PulseQobjInstruction,
                                               meas_level=2)
        instruction = Acquire(10, AcquireChannel(0), MemorySlot(0),
                              RegisterSlot(0))
        valid_qobj = PulseQobjInstruction(name='acquire',
                                          t0=0,
                                          duration=10,
                                          qubits=[0],
                                          memory_slot=[0],
                                          register_slot=[0])
        self.assertEqual(converter(0, instruction), valid_qobj)

        # without register
        instruction = Acquire(10, AcquireChannel(0), MemorySlot(0))
        valid_qobj = PulseQobjInstruction(name='acquire',
                                          t0=0,
                                          duration=10,
                                          qubits=[0],
                                          memory_slot=[0])
        self.assertEqual(converter(0, instruction), valid_qobj)
    def test_acquire(self):
        """Test converted qobj from Acquire."""
        schedule = Schedule()
        for i in range(self.num_qubits):
            schedule |= Acquire(
                10,
                AcquireChannel(i),
                MemorySlot(i),
                RegisterSlot(i),
                kernel=Kernel(name="test_kern", test_params="test"),
                discriminator=Discriminator(name="test_disc", test_params=1.0),
            )

        qobj = PulseQobjInstruction(
            name="acquire",
            t0=0,
            duration=10,
            qubits=[0, 1],
            memory_slot=[0, 1],
            register_slot=[0, 1],
            kernels=[
                QobjMeasurementOption(name="test_kern",
                                      params={"test_params": "test"})
            ],
            discriminators=[
                QobjMeasurementOption(name="test_disc",
                                      params={"test_params": 1.0})
            ],
        )
        converted_instruction = self.converter(qobj)

        self.assertEqual(converted_instruction.start_time, 0)
        self.assertEqual(converted_instruction.duration, 10)
        self.assertEqual(converted_instruction.instructions[0][-1].duration,
                         10)
        self.assertEqual(
            converted_instruction.instructions[0][-1].kernel.params,
            {"test_params": "test"})
        self.assertEqual(converted_instruction.instructions[1][-1].channel,
                         AcquireChannel(1))