Skip to content

Commit 01d78ba

Browse files
author
Erik Nielsen
committed
Added seed argument to list_random_gatestrings_onelen
1 parent a950406 commit 01d78ba

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/pygsti/construction/gatestringconstruction.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def pow_check(testStr,strListDict):
344344
return output
345345

346346

347-
def list_random_gatestrings_onelen(gateLabels, length, count):
347+
def list_random_gatestrings_onelen(gateLabels, length, count, seed=None):
348348
"""
349349
Create a list of random gate strings of a given length.
350350
@@ -359,14 +359,19 @@ def list_random_gatestrings_onelen(gateLabels, length, count):
359359
count : int
360360
the number of random strings to create.
361361
362+
seed : int, optional
363+
If not None, a seed for numpy's random number generator.
364+
365+
362366
Returns
363367
-------
364368
list of GateStrings
365369
A list of random gate strings as GateString objects.
366370
"""
367371
ret = [ ]
372+
rndm = _rndm.RandomState(seed) # ok if seed is None
368373
for i in range(count):
369-
r = _rndm.random(length) * len(gateLabels)
374+
r = rndm.random(length) * len(gateLabels)
370375
ret.append( _gs.GateString( [gateLabels[int(k)] for k in r]) )
371376
return ret
372377

0 commit comments

Comments
 (0)