mardi 20 février 2018

How to fix random_state in random.sample

I'm making unittests for my code and need to fix random state, but It doesn't work. Does anybody have an idea how to deal with it? Here is simple example:

swap=5
while swap>0:
    random_state=0
    a,b,c=random.sample(range(10), 3)
    print(a,b,c)
    swap=swap-1

I get:

5 7 2
5 6 4
9 3 4
2 9 7
8 3 7

I need:

5 7 2
5 7 2
5 7 2
5 7 2
5 7 2




Aucun commentaire:

Enregistrer un commentaire