Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Redefine slope of RampWaveform #644

Merged
merged 4 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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