random.py 328 Bytes
Newer Older
Theo Steininger's avatar
Theo Steininger committed
1
2
3
4
# -*- coding: utf-8 -*-

import numpy as np

5
6
from .config import configuration as gc,\
                    dependency_injector as gdi
Theo Steininger's avatar
Theo Steininger committed
7
8

MPI = gdi[gc['mpi_module']]
Theo Steininger's avatar
Theo Steininger committed
9
comm = getattr(MPI, gc['default_comm'])
Theo Steininger's avatar
Theo Steininger committed
10
11
12
13
14
15
rank = comm.rank


def seed(seed=None):
    seed = rank if seed is None else np.uint32(seed) + rank
    np.random.seed(seed)