param seed changed to random_state
This commit is contained in:
parent
cef20d8b32
commit
8f6aa629b8
|
@ -57,17 +57,17 @@ def parallel(func, args, n_jobs):
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@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.:
|
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):
|
>>> with temp_seed(random_seed):
|
||||||
>>> pass # do any computation depending on np.random functionality
|
>>> 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()
|
state = np.random.get_state()
|
||||||
np.random.seed(seed)
|
np.random.seed(random_state)
|
||||||
try:
|
try:
|
||||||
yield
|
yield
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Reference in New Issue