forked from M-Labs/artiq
1
0
Fork 0

language/scan: add len() support

This commit is contained in:
Sebastien Bourdeauducq 2015-10-12 16:06:12 +08:00
parent cd3b590962
commit 7414b90da3
1 changed files with 12 additions and 0 deletions

View File

@ -47,6 +47,9 @@ class NoScan(ScanObject):
def __iter__(self):
return self._gen()
def __len__(self):
return 1
def describe(self):
return {"ty": "NoScan", "value": self.value}
@ -70,6 +73,9 @@ class LinearScan(ScanObject):
def __iter__(self):
return self._gen()
def __len__(self):
return self.npoints
def describe(self):
return {"ty": "LinearScan",
"min": self.min, "max": self.max, "npoints": self.npoints}
@ -89,6 +95,9 @@ class RandomScan(ScanObject):
def __iter__(self):
return iter(self.sequence)
def __len__(self):
return self.npoints
def describe(self):
return {"ty": "RandomScan",
"min": self.min, "max": self.max, "npoints": self.npoints}
@ -103,6 +112,9 @@ class ExplicitScan(ScanObject):
def __iter__(self):
return iter(self.sequence)
def __len__(self):
return len(self.sequence)
def describe(self):
return {"ty": "ExplicitScan", "sequence": self.sequence}