Skip to content

common

Common functions for all modules.

set_seed(seed=None)

(Potentially) set the seed for numpy, torch and random. If no seed is provided, nothing happens.

Parameters:

Name Type Description Default
seed Optional[int]

The seed to set.

None
Source code in src/nhssynth/common/common.py
def set_seed(seed: Optional[int] = None) -> None:
    """
    (Potentially) set the seed for numpy, torch and random. If no seed is provided, nothing happens.

    Args:
        seed: The seed to set.
    """
    if seed:
        np.random.seed(seed)
        torch.manual_seed(seed)
        random.seed(seed)