def test_gaussian_deriv(self): """Test gaussian derivative pulse.""" amp = 0.5 center = 10 sigma = 2 times, dt = np.linspace(0, 20, 1000, retstep=True) deriv_prefactor = -sigma**2/(times-center) gaussian_deriv_arr = continuous.gaussian_deriv(times, amp, center, sigma) gaussian_arr = gaussian_deriv_arr*deriv_prefactor self.assertEqual(gaussian_deriv_arr.dtype, np.complex_) self.assertAlmostEqual(continuous.gaussian_deriv(np.array([0]), amp, center, sigma)[0], 0, places=5) self.assertAlmostEqual(np.sum(gaussian_arr*dt), amp*np.sqrt(2*np.pi*sigma**2), places=3)
def test_gaussian_deriv(self): """Test discrete sampled gaussian derivative pulse.""" amp = 0.5 sigma = 2 duration = 10 center = duration/2 times = np.arange(0, duration) gaussian_deriv_ref = continuous.gaussian_deriv(times, amp, center, sigma) gaussian_deriv_pulse = pulse_lib.gaussian_deriv(duration, amp, sigma) self.assertIsInstance(gaussian_deriv_pulse, SamplePulse) np.testing.assert_array_almost_equal(gaussian_deriv_pulse.samples, gaussian_deriv_ref)