changed helper random file
This commit is contained in:
parent
611eb9db87
commit
c590738471
|
@ -1,5 +1,5 @@
|
||||||
import os
|
import os
|
||||||
import random
|
|
||||||
from pyelliptic.openssl import OpenSSL
|
from pyelliptic.openssl import OpenSSL
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,35 +9,3 @@ def randomBytes(n):
|
||||||
return os.urandom(n)
|
return os.urandom(n)
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
return OpenSSL.rand(n)
|
return OpenSSL.rand(n)
|
||||||
|
|
||||||
|
|
||||||
def randomshuffle(population):
|
|
||||||
"""Method randomShuffle.
|
|
||||||
|
|
||||||
shuffle the sequence x in place.
|
|
||||||
shuffles the elements in list in place,
|
|
||||||
so they are in a random order.
|
|
||||||
"""
|
|
||||||
return random.shuffle(population)
|
|
||||||
|
|
||||||
|
|
||||||
def randomsample(population, k):
|
|
||||||
"""Method randomSample.
|
|
||||||
|
|
||||||
return a k length list of unique elements
|
|
||||||
chosen from the population sequence.
|
|
||||||
Used for random sampling
|
|
||||||
without replacement
|
|
||||||
"""
|
|
||||||
return random.sample(population, k)
|
|
||||||
|
|
||||||
|
|
||||||
def randomrandrange(x, y):
|
|
||||||
"""Method randomRandrange.
|
|
||||||
|
|
||||||
return a randomly selected element from
|
|
||||||
range(start, stop). This is equivalent to
|
|
||||||
choice(range(start, stop)),
|
|
||||||
but doesnt actually build a range object.
|
|
||||||
"""
|
|
||||||
return random.randrange(x, y)
|
|
||||||
|
|
Reference in New Issue
Block a user