param seed changed to random_state

This commit is contained in:
Alejandro Moreo Fernandez 2022-06-21 10:49:30 +02:00
parent cef20d8b32
commit 8f6aa629b8
1 changed files with 3 additions and 3 deletions

View File

@ -57,17 +57,17 @@ def parallel(func, args, n_jobs):
@contextlib.contextmanager
def temp_seed(seed):
def temp_seed(random_state):
"""
Can be used in a "with" context to set a temporal seed without modifying the outer numpy's current state. E.g.:
>>> with temp_seed(random_seed):
>>> pass # do any computation depending on np.random functionality
:param seed: the seed to set within the "with" context
:param random_state: the seed to set within the "with" context
"""
state = np.random.get_state()
np.random.seed(seed)
np.random.seed(random_state)
try:
yield
finally: