(seed)
Context manager that temporarily sets the numpy.random seed.
Context manager that temporarily sets the numpy.random seed.
Context manager that temporarily sets the numpy . random seed .
def numpy_seed(seed):
  """Context manager that temporarily sets the numpy.random seed."""
  if seed is not None:
    prev_rng_state = np.random.get_state()
    np.random.seed(seed)
  yield
  if seed is not None:
    np.random.set_state(prev_rng_state)
def numpy_seed ( seed ) : if seed is not None : prev_rng_state = np . random . get_state ( ) np . random . seed ( seed ) yield if seed is not None : np . random . set_state ( prev_rng_state )