/usr/share/pyshared/mvpa2/_random.py is in python-mvpa2 2.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
# See COPYING file distributed along with the PyMVPA package for the
# copyright and license terms.
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Helper module for control of RNGs (numpy and stock python)"""
import random
import numpy as np
from mvpa2.base import cfg
if __debug__:
from mvpa2.base import debug
#
# RNG seeding
#
if cfg.has_option('general', 'seed'):
_random_seed = cfg.getint('general', 'seed')
else:
_random_seed = int(np.random.uniform()*(2**31-1))
def seed(random_seed):
"""Uniform and combined seeding of all relevant random number
generators.
"""
if __debug__:
debug('RANDOM', 'Reseeding RNGs with %s' % random_seed)
np.random.seed(random_seed)
random.seed(random_seed)
seed(_random_seed)
|