Exemple #1
0
 def test_drag_pulse(self):
     """Test that the Drag sample pulse matches the pulse library."""
     drag = Drag(duration=25, sigma=4, amp=0.5j, beta=1)
     sample_pulse = drag.get_sample_pulse()
     self.assertIsInstance(sample_pulse, Waveform)
     pulse_lib_drag = pl_drag(duration=25, sigma=4, amp=0.5j, beta=1, zero_ends=True).samples
     np.testing.assert_almost_equal(sample_pulse.samples, pulse_lib_drag)
 def test_drag_validation(self):
     """Test drag parameter validation, specifically the beta validation."""
     duration = 25
     sigma = 4
     amp = 0.5j
     beta = 1
     wf = Drag(duration=duration, sigma=sigma, amp=amp, beta=beta)
     samples = wf.get_sample_pulse().samples
     self.assertTrue(max(np.abs(samples)) <= 1)
     beta = sigma**2
     with self.assertRaises(PulseError):
         wf = Drag(duration=duration, sigma=sigma, amp=amp, beta=beta)
     # If sigma is high enough, side peaks fall out of range and norm restriction is met
     sigma = 100
     wf = Drag(duration=duration, sigma=sigma, amp=amp, beta=beta)
 def test_drag_samples(self):
     """Test that the drag samples match the formula."""
     duration = 25
     sigma = 4
     amp = 0.5j
     beta = 1
     # formulaic
     times = np.array(range(25), dtype=np.complex_)
     times = times - (25 / 2) + 0.5
     gauss = amp * np.exp(-(times / sigma)**2 / 2)
     gauss_deriv = -(times / sigma**2) * gauss
     drag = gauss + 1j * beta * gauss_deriv
     # wf
     wf = Drag(duration=duration, sigma=sigma, amp=amp, beta=beta)
     samples = wf.get_sample_pulse().samples
     np.testing.assert_almost_equal(samples, drag)
 def check_drag(duration, sigma, amp, beta):
     wf = Drag(duration=duration, sigma=sigma, amp=amp, beta=beta)
     samples = wf.get_sample_pulse().samples
     self.assertTrue(max(np.abs(samples)) <= 1)