Skip to content
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
9 changes: 9 additions & 0 deletions tests/tendencies/test_repeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,12 @@ def test_filled(repeat_waveform):
assert tendencies[2].base == 2
assert tendencies[2].amplitude == -1
assert tendencies[2].frequency == 0.25


def test_too_short(repeat_waveform):
"""Check for warning in annotations if repeated waveform has not completed a
single repetition."""
repeat_waveform["user_duration"] = 2
repeat_tendency = RepeatTendency(**repeat_waveform)
assert repeat_tendency.annotations
assert repeat_tendency.annotations[0]["type"] == "warning"
11 changes: 9 additions & 2 deletions waveform_editor/tendencies/repeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,21 @@ def __init__(self, **kwargs):

self.waveform = Waveform(waveform=waveform, is_repeated=True)
if not self.waveform.tendencies:
error_msg = "There are no tendencies in the repeated waveform."
error_msg = "There are no tendencies in the repeated waveform.\n"
self.annotations.add(self.line_number, error_msg)
return

if self.waveform.tendencies[0].start != 0:
error_msg = "The starting point of the first repeated must be set to 0."
error_msg = "The starting point of the first repeated must be set to 0.\n"
self.annotations.add(self.line_number, error_msg)

if self.duration < self.waveform.tendencies[-1].end:
error_msg = (
"The repeated tendency has not completed a single repetition.\n"
"Perhaps increase the duration of the repeated tendency?\n"
)
self.annotations.add(self.line_number, error_msg, is_warning=True)

# Link the last tendency to the first tendency in the repeated waveform
# We must lock the start to 0, otherwise it will take the start value of the
# previous tendency.
Expand Down