Skip to content

Commit

Permalink
FIX: Redefine slope of RampWaveform (#644)
Browse files Browse the repository at this point in the history
* Redefine slope

* Modify docstring

* Fix docstring
  • Loading branch information
a-corni authored Feb 12, 2024
1 parent 7b7918b commit 20e6765
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pulser-core/pulser/waveforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_waveforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 20e6765

Please sign in to comment.