nimble.random.alternateControl

nimble.random.alternateControl(seed=None, *, useLog=None)

Context manager to operate outside of the current random state.

Saves the state prior to entering, changes the state on entry, and restores the original state on exit. The setSeed function is disallowed while within the context manager as this would modify the controlled state. However, these objects can be nested to achieve a different state while already within a controlled state.

Parameters:
  • seed (int) – Seed for random state. Must be convertible to 32 bit unsigned integer for compliance with numpy. If seed is None, the operating system’s randomness sources are used if available otherwise the system time is used.

  • useLog (bool, None) – Local control for whether to send object creation to the logger. If None (default), use the value as specified in the “logger” “enabledByDefault” configuration option. If True, send to the logger regardless of the global option. If False, do NOT send to the logger, regardless of the global option.