diff --git a/pulser-core/pulser/waveforms.py b/pulser-core/pulser/waveforms.py index fe6a493d9..0a7bdfbb0 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 (in rad/µs). + start: The value (in rad/µs) at the initial sample. + stop: The value (in rad/µs) at the final sample. """ 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 06dd291b6..31bbb4a37 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():