Skip to content

Commit cb3cbd0

Browse files
committed
give warning if repeated tendency has not completed a cycle
1 parent 4f2beaf commit cb3cbd0

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

tests/tendencies/test_repeat.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,10 @@ def test_filled(repeat_waveform):
166166
assert tendencies[2].base == 2
167167
assert tendencies[2].amplitude == -1
168168
assert tendencies[2].frequency == 0.25
169+
170+
171+
def test_too_short(repeat_waveform):
172+
"""Test for warning if repeated waveform does not have a single repetition."""
173+
repeat_waveform["user_duration"] = 2
174+
repeat_tendency = RepeatTendency(**repeat_waveform)
175+
assert repeat_tendency.annotations

waveform_editor/tendencies/repeat.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,21 @@ def __init__(self, **kwargs):
1818

1919
self.waveform = Waveform(waveform=waveform, is_repeated=True)
2020
if not self.waveform.tendencies:
21-
error_msg = "There are no tendencies in the repeated waveform."
21+
error_msg = "There are no tendencies in the repeated waveform.\n"
2222
self.annotations.add(self.line_number, error_msg)
2323
return
2424

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

29+
if self.duration < self.waveform.tendencies[-1].end:
30+
error_msg = (
31+
"The repeated tendency has not completed a single repetition.\n"
32+
"Perhaps increase the length of the repeated tendency?\n"
33+
)
34+
self.annotations.add(self.line_number, error_msg, is_warning=True)
35+
2936
# Link the last tendency to the first tendency in the repeated waveform
3037
# We must lock the start to 0, otherwise it will take the start value of the
3138
# previous tendency.

0 commit comments

Comments
 (0)