Skip to content

Commit e289f07

Browse files
author
David Butterworth
committed
VanDerCorputSampleGenerator() can only generate a monotonically-increasing sequence so do some checks on the input.
1 parent c7f2c9f commit e289f07

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/prpy/util.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,14 @@ def VanDerCorputSampleGenerator(start, end, step=2):
10801080
"""
10811081
import itertools
10821082

1083+
# 'start' and 'end' must be positive because
1084+
# itertools.islice() only accepts a positive integer
1085+
if end <= start:
1086+
raise ValueError("The 'end' value must be greater than "\
1087+
"the 'start' value.")
1088+
if not (step > 0):
1089+
raise ValueError("The 'step' value must be positive.")
1090+
10831091
# The duration, rounded to nearest step-size
10841092
mod_end = int(end - (end % step))
10851093
steps_to_take = mod_end / float(step)

0 commit comments

Comments
 (0)