diff --git a/quil-py/src/waveforms.rs b/quil-py/src/waveforms.rs index 912cfa2c..486c2345 100644 --- a/quil-py/src/waveforms.rs +++ b/quil-py/src/waveforms.rs @@ -109,6 +109,35 @@ impl_into_iq_values!(PyErfSquare); impl_repr!(PyErfSquare); impl_eq!(PyErfSquare); +#[pymethods] +impl PyErfSquare { + #[new] + #[allow(clippy::too_many_arguments)] + fn __new__( + duration: f64, + risetime: f64, + sample_rate: f64, + pad_left: f64, + pad_right: f64, + positive_polarity: bool, + scale: f64, + phase: f64, + detuning: f64, + ) -> Self { + PyErfSquare(ErfSquare { + duration, + risetime, + sample_rate, + pad_left, + pad_right, + positive_polarity, + scale, + phase, + detuning, + }) + } +} + py_wrap_data_struct! { #[derive(Debug, PartialEq)] #[pyo3(subclass)] @@ -126,6 +155,30 @@ impl_into_iq_values!(PyGaussian); impl_repr!(PyGaussian); impl_eq!(PyGaussian); +#[pymethods] +impl PyGaussian { + #[new] + fn __new__( + duration: f64, + fwhm: f64, + t0: f64, + sample_rate: f64, + scale: f64, + phase: f64, + detuning: f64, + ) -> Self { + PyGaussian(Gaussian { + duration, + fwhm, + t0, + sample_rate, + scale, + phase, + detuning, + }) + } +} + py_wrap_data_struct! { #[derive(Debug, PartialEq)] #[pyo3(subclass)] @@ -145,6 +198,35 @@ impl_into_iq_values!(PyDragGaussian); impl_repr!(PyDragGaussian); impl_eq!(PyDragGaussian); +#[pymethods] +impl PyDragGaussian { + #[new] + #[allow(clippy::too_many_arguments)] + fn __new__( + duration: f64, + fwhm: f64, + t0: f64, + anh: f64, + alpha: f64, + sample_rate: f64, + scale: f64, + phase: f64, + detuning: f64, + ) -> Self { + PyDragGaussian(DragGaussian { + duration, + fwhm, + t0, + anh, + alpha, + sample_rate, + scale, + phase, + detuning, + }) + } +} + py_wrap_data_struct! { #[derive(Debug, PartialEq)] #[pyo3(subclass)] @@ -164,3 +246,34 @@ py_wrap_data_struct! { impl_into_iq_values!(PyHermiteGaussian); impl_repr!(PyHermiteGaussian); impl_eq!(PyHermiteGaussian); + +#[pymethods] +impl PyHermiteGaussian { + #[allow(clippy::too_many_arguments)] + #[new] + fn __new__( + duration: f64, + fwhm: f64, + t0: f64, + anh: f64, + alpha: f64, + sample_rate: f64, + second_order_hrm_coeff: f64, + scale: f64, + phase: f64, + detuning: f64, + ) -> Self { + PyHermiteGaussian(HermiteGaussian { + duration, + fwhm, + t0, + anh, + alpha, + sample_rate, + second_order_hrm_coeff, + scale, + phase, + detuning, + }) + } +} diff --git a/quil-py/tests_py/test_waveform.py b/quil-py/tests_py/test_waveform.py new file mode 100644 index 00000000..e7e1e354 --- /dev/null +++ b/quil-py/tests_py/test_waveform.py @@ -0,0 +1,24 @@ +from quil.waveforms import ErfSquare, BoxcarKernel, apply_phase_and_detuning, DragGaussian, Gaussian, HermiteGaussian + + +def test_apply_phase_and_detuning(): + iq_values = [1.0, 0.0, 1.0, 0.0] + apply_phase_and_detuning(iq_values, 0, 0, 44100) + assert iq_values == [0, 0, 0, 0] + + +class TestConstrutor: + def test_boxcar_kernel(self): + BoxcarKernel(0.0, 0.0, 0.0) + + def test_erf_square(self): + ErfSquare(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) + + def test_gaussian(self): + Gaussian(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) + + def test_drag_gaussian(self): + DragGaussian(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) + + def test_hermite_gaussian(self): + DragGaussian(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)