forked from M-Labs/artiq
language/scan: add len() support
This commit is contained in:
parent
cd3b590962
commit
7414b90da3
|
@ -47,6 +47,9 @@ class NoScan(ScanObject):
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self._gen()
|
return self._gen()
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return 1
|
||||||
|
|
||||||
def describe(self):
|
def describe(self):
|
||||||
return {"ty": "NoScan", "value": self.value}
|
return {"ty": "NoScan", "value": self.value}
|
||||||
|
|
||||||
|
@ -70,6 +73,9 @@ class LinearScan(ScanObject):
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self._gen()
|
return self._gen()
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return self.npoints
|
||||||
|
|
||||||
def describe(self):
|
def describe(self):
|
||||||
return {"ty": "LinearScan",
|
return {"ty": "LinearScan",
|
||||||
"min": self.min, "max": self.max, "npoints": self.npoints}
|
"min": self.min, "max": self.max, "npoints": self.npoints}
|
||||||
|
@ -89,6 +95,9 @@ class RandomScan(ScanObject):
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return iter(self.sequence)
|
return iter(self.sequence)
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return self.npoints
|
||||||
|
|
||||||
def describe(self):
|
def describe(self):
|
||||||
return {"ty": "RandomScan",
|
return {"ty": "RandomScan",
|
||||||
"min": self.min, "max": self.max, "npoints": self.npoints}
|
"min": self.min, "max": self.max, "npoints": self.npoints}
|
||||||
|
@ -103,6 +112,9 @@ class ExplicitScan(ScanObject):
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return iter(self.sequence)
|
return iter(self.sequence)
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(self.sequence)
|
||||||
|
|
||||||
def describe(self):
|
def describe(self):
|
||||||
return {"ty": "ExplicitScan", "sequence": self.sequence}
|
return {"ty": "ExplicitScan", "sequence": self.sequence}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue