From fe7a5f8927d11c8f0e21bb2532a3607a6f72ab32 Mon Sep 17 00:00:00 2001 From: a_corni Date: Mon, 12 Feb 2024 12:17:25 +0100 Subject: [PATCH 1/3] Redefine slope --- pulser-core/pulser/waveforms.py | 4 ++-- tests/test_waveforms.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pulser-core/pulser/waveforms.py b/pulser-core/pulser/waveforms.py index fe6a493d..b697f0f8 100644 --- a/pulser-core/pulser/waveforms.py +++ b/pulser-core/pulser/waveforms.py @@ -533,7 +533,7 @@ class RampWaveform(Waveform): Args: duration: The waveform duration (in ns). start: The initial value (in rad/µs). - stop: The final value (in rad/µs). + stop: The final value at duration - 1 (in rad/µs). """ def __init__( @@ -566,7 +566,7 @@ def _samples(self) -> np.ndarray: @property def slope(self) -> float: r"""Slope of the ramp, in :math:`s^{-15}`.""" - return (self._stop - self._start) / self._duration + return (self._stop - self._start) / (self._duration - 1) def change_duration(self, new_duration: int) -> RampWaveform: """Returns a new waveform with modified duration. diff --git a/tests/test_waveforms.py b/tests/test_waveforms.py index 06dd291b..31bbb4a3 100644 --- a/tests/test_waveforms.py +++ b/tests/test_waveforms.py @@ -162,7 +162,7 @@ def test_custom(): def test_ramp(): - assert ramp.slope == 7e-3 + assert np.isclose(ramp.slope, 7e-3, atol=1e-5) def test_blackman(): From 5c2c4c5d73e85602a0e03c6654ed2173f9d7ef53 Mon Sep 17 00:00:00 2001 From: a_corni Date: Mon, 12 Feb 2024 14:11:22 +0100 Subject: [PATCH 2/3] Modify docstring --- pulser-core/pulser/waveforms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pulser-core/pulser/waveforms.py b/pulser-core/pulser/waveforms.py index b697f0f8..1c476338 100644 --- a/pulser-core/pulser/waveforms.py +++ b/pulser-core/pulser/waveforms.py @@ -532,8 +532,8 @@ class RampWaveform(Waveform): Args: duration: The waveform duration (in ns). - start: The initial value (in rad/µs). - stop: The final value at duration - 1 (in rad/µs). + start: The value (in rad/µs) at the initial sample. + stop: The value (in rad/µs) at the initial sample. """ def __init__( From 6706162c88b9a06ed20c7dede9e309abf562a119 Mon Sep 17 00:00:00 2001 From: a_corni Date: Mon, 12 Feb 2024 14:15:16 +0100 Subject: [PATCH 3/3] Fix docstring --- pulser-core/pulser/waveforms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pulser-core/pulser/waveforms.py b/pulser-core/pulser/waveforms.py index 1c476338..0a7bdfbb 100644 --- a/pulser-core/pulser/waveforms.py +++ b/pulser-core/pulser/waveforms.py @@ -533,7 +533,7 @@ class RampWaveform(Waveform): Args: duration: The waveform duration (in ns). start: The value (in rad/µs) at the initial sample. - stop: The value (in rad/µs) at the initial sample. + stop: The value (in rad/µs) at the final sample. """ def __init__(