From aa26b13816393c0cf6607c8540058ccfe1fb682b Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 23 May 2016 14:29:42 -0700 Subject: [PATCH] language/RandomScan: automatic seed by default --- artiq/language/scan.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/artiq/language/scan.py b/artiq/language/scan.py index 8b88a9f5f..7ead27f62 100644 --- a/artiq/language/scan.py +++ b/artiq/language/scan.py @@ -18,7 +18,7 @@ iterators are independent from each other. Scan objects are supported both on the host and the core device. """ -from random import Random, shuffle +import random import inspect from artiq.language.core import * @@ -89,12 +89,16 @@ class LinearScan(ScanObject): class RandomScan(ScanObject): """A scan object that yields a fixed number of randomly ordered evenly spaced values in a range.""" - def __init__(self, start, stop, npoints, seed=0): + def __init__(self, start, stop, npoints, seed=None): self.start = start self.stop = stop self.npoints = npoints self.sequence = list(LinearScan(start, stop, npoints)) - shuffle(self.sequence, Random(seed).random) + if seed is None: + rf = random.random + else: + rf = Random(seed).random + random.shuffle(self.sequence, rf) @portable def __iter__(self):