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

import numpy as np

from d2o.config import configuration as gc,\
                       dependency_injector as gdi

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)