forked from M-Labs/artiq
1
0
Fork 0

scan: enforce max >= min

This commit is contained in:
Sebastien Bourdeauducq 2015-11-30 20:01:25 +08:00
parent 277e26434f
commit a6f3055cd3
2 changed files with 4 additions and 1 deletions

View File

@ -38,7 +38,6 @@ class _NoScan(LayoutWidget):
self.value.valueChanged.connect(update) self.value.valueChanged.connect(update)
# TODO: prevent max < min
class _Range(LayoutWidget): class _Range(LayoutWidget):
def __init__(self, procdesc, state): def __init__(self, procdesc, state):
LayoutWidget.__init__(self) LayoutWidget.__init__(self)

View File

@ -58,6 +58,8 @@ class LinearScan(ScanObject):
"""A scan object that yields a fixed number of increasing evenly """A scan object that yields a fixed number of increasing evenly
spaced values in a range.""" spaced values in a range."""
def __init__(self, min, max, npoints): def __init__(self, min, max, npoints):
if min > max:
raise ValueError("Scan minimum must be less than maximum")
self.min = min self.min = min
self.max = max self.max = max
self.npoints = npoints self.npoints = npoints
@ -85,6 +87,8 @@ class RandomScan(ScanObject):
"""A scan object that yields a fixed number of randomly ordered evenly """A scan object that yields a fixed number of randomly ordered evenly
spaced values in a range.""" spaced values in a range."""
def __init__(self, min, max, npoints, seed=0): def __init__(self, min, max, npoints, seed=0):
if min > max:
raise ValueError("Scan minimum must be less than maximum")
self.min = min self.min = min
self.max = max self.max = max
self.npoints = npoints self.npoints = npoints