From 7414b90da3775cc7fc8d45ad5872f9f1ceec3202 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 12 Oct 2015 16:06:12 +0800 Subject: [PATCH] language/scan: add len() support --- artiq/language/scan.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/artiq/language/scan.py b/artiq/language/scan.py index a5ffa27d6..7bc5d5665 100644 --- a/artiq/language/scan.py +++ b/artiq/language/scan.py @@ -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}