示例#1
0
 def test_gaussian_square_pulse(self):
     """Test that GaussianSquare sample pulse matches the pulse library."""
     gauss_sq = GaussianSquare(duration=125, sigma=4, amp=0.5j, width=100)
     sample_pulse = gauss_sq.get_waveform()
     self.assertIsInstance(sample_pulse, Waveform)
     pulse_lib_gauss_sq = gaussian_square(duration=125,
                                          sigma=4,
                                          amp=0.5j,
                                          width=100,
                                          zero_ends=True).samples
     np.testing.assert_almost_equal(sample_pulse.samples,
                                    pulse_lib_gauss_sq)
     gauss_sq = GaussianSquare(duration=125,
                               sigma=4,
                               amp=0.5j,
                               risefall_sigma_ratio=3.125)
     sample_pulse = gauss_sq.get_waveform()
     self.assertIsInstance(sample_pulse, Waveform)
     pulse_lib_gauss_sq = gaussian_square(duration=125,
                                          sigma=4,
                                          amp=0.5j,
                                          width=100,
                                          zero_ends=True).samples
     np.testing.assert_almost_equal(sample_pulse.samples,
                                    pulse_lib_gauss_sq)
示例#2
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
示例#3
0
 def test_gaussian_square_args(self):
     """Gaussian square allows the user to specify risefall or width. Test this."""
     amp = 0.5
     sigma = 0.1
     duration = 10
     # risefall and width consistent: no error
     library.gaussian_square(duration, amp, sigma, 2, width=6)
     # supply width instead: no error
     library.gaussian_square(duration, amp, sigma, width=6)
     with self.assertRaises(PulseError):
         library.gaussian_square(duration, amp, sigma, width=2, risefall=2)
     with self.assertRaises(PulseError):
         library.gaussian_square(duration, amp, sigma)
示例#4
0
 def test_gaussian_square(self):
     """Test discrete sampled gaussian square pulse."""
     amp = 0.5
     sigma = 0.1
     risefall = 2
     duration = 10
     center = duration/2
     width = duration-2*risefall
     center = duration/2
     times = np.arange(0, duration) + 0.5
     gaussian_square_ref = continuous.gaussian_square(times, amp, center, width, sigma)
     gaussian_square_pulse = library.gaussian_square(duration, amp, sigma, risefall)
     self.assertIsInstance(gaussian_square_pulse, Waveform)
     np.testing.assert_array_almost_equal(gaussian_square_pulse.samples, gaussian_square_ref)