Ejemplo n.º 1
0
 def test_gauss_square_extremes(self):
     """Test that the gaussian square pulse can build a gaussian."""
     duration = 125
     sigma = 4
     amp = 0.5j
     gaus_square = GaussianSquare(duration=duration, sigma=sigma, amp=amp, width=0)
     gaus = Gaussian(duration=duration, sigma=sigma, amp=amp)
     np.testing.assert_almost_equal(gaus_square.get_sample_pulse().samples,
                                    gaus.get_sample_pulse().samples)
     gaus_square = GaussianSquare(duration=duration, sigma=sigma, amp=amp, width=121)
     const = Constant(duration=duration, amp=amp)
     np.testing.assert_almost_equal(gaus_square.get_sample_pulse().samples[2:-2],
                                    const.get_sample_pulse().samples[2:-2])
Ejemplo n.º 2
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_sample_pulse()
     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)
Ejemplo n.º 3
0
 def test_gauss_square_samples(self):
     """Test that the gaussian square samples match the formula."""
     duration = 125
     sigma = 4
     amp = 0.5j
     # formulaic
     times = np.array(range(25), dtype=np.complex_)
     times = times - (25 / 2) + 0.5
     gauss = amp * np.exp(-(times / sigma)**2 / 2)
     # wf
     wf = GaussianSquare(duration=duration, sigma=sigma, amp=amp, width=100)
     samples = wf.get_sample_pulse().samples
     np.testing.assert_almost_equal(samples[50], amp)
     np.testing.assert_almost_equal(samples[100], amp)
     np.testing.assert_almost_equal(samples[:10], gauss[:10])