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

Add duration property in sequence #810

Merged
merged 4 commits into from
Mar 4, 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
11 changes: 11 additions & 0 deletions src/broadbean/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,17 @@ def points(self):
total += elem.points
return total

@property
def duration(self) -> float:
"""
Returns the duration in seconds of the sequence.
"""
duration = 0.0
for pos, elem in self._data.items():
nrep = self._sequencing[pos]["nrep"]
duration += nrep * elem.duration
return duration

def element(self, pos):
"""
Returns the element at the given position. Changes made to the return
Expand Down
8 changes: 8 additions & 0 deletions tests/test_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,14 @@ def test_add_subsequence_raises(protosequence1, squarepulse_baseelem):
doublemainseq.addSubSequence(1, mainseq)


##################################################
# Sequence properties

def test_duration(protosequence1, protosequence2):
assert np.round(protosequence1.duration, 12) == 50e-6
assert np.round(protosequence2.duration, 12) == 75e-6


##################################################
# AWG settings

Expand Down