I have two modules, the first of which which is:
# module.py
import numpy
import myrandom
class A():
def __init__(self,n1,n2):
A.rng_set1 = myrandom.generate_random(n1)
A.rng_set2 = myrandom.generate_random(n2)
A.data = np.concatenate((A.rng_set1,A.rng_set2))
The module myrandom
is something like:
# myrandom.py
import numpy as np
def generate_random(n):
return np.random.rand(n)
Given a seed I want A.data
to be predictable. I don't want rng_set1
and rng_set2
to share the same numbers if n1
equals n2
. I don't understand how to seed this thing.
I've tried putting np.random.seed(constant)
into generate_random
, into A
's init, at module.py
top level and before import module.py
. I can't seem to get the desired result.
How am i supposed to do this? Thank you.
Aucun commentaire:
Enregistrer un commentaire