Skip to content

Commit

Permalink
language/RandomScan: automatic seed by default
Browse files Browse the repository at this point in the history
sbourdeauducq committed May 23, 2016
1 parent 42c84e0 commit aa26b13
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions artiq/language/scan.py
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
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 @@ def describe(self):
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):

0 comments on commit aa26b13

Please sign in to comment.