I have a function which do some random things..
And I want to input seed to it, so for same seeds the output will be the same..
But initiating the seed at the beggining like this:
def generate_random_number(seed): np.random.seed(seed) magics = np.random.random(1) more_magics = ... return magics, more_magics Will result that after calling this method, the seed is ruined.
Is there a way to "save" the current seed state and restore it later?
So it will look something like this:
def generate_random_number_without_ruining_for_others(seed): old_seed = np.random.get_seed() np.random.seed(seed) magics = np.random.random(1) more_magics = ... np.random.seed(old_seed) return magics, more_magics Of course, the command: np.random.get_seed() is a made-up function.. is there something like this? Or alternative approach to generate "random" (up to seed input) output without destroying everyone's randomness state?
(The actual random process is much more complicated in practice, it generates matrices in loop so I would like to stick with the format of initiating seed at the beggining for simplicity)