Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/numpy/random/_pickle.py : 45%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from .mtrand import RandomState
2from ._philox import Philox
3from ._pcg64 import PCG64
4from ._sfc64 import SFC64
6from ._generator import Generator
7from ._mt19937 import MT19937
9BitGenerators = {'MT19937': MT19937,
10 'PCG64': PCG64,
11 'Philox': Philox,
12 'SFC64': SFC64,
13 }
16def __generator_ctor(bit_generator_name='MT19937'):
17 """
18 Pickling helper function that returns a Generator object
20 Parameters
21 ----------
22 bit_generator_name: str
23 String containing the core BitGenerator
25 Returns
26 -------
27 rg: Generator
28 Generator using the named core BitGenerator
29 """
30 if bit_generator_name in BitGenerators:
31 bit_generator = BitGenerators[bit_generator_name]
32 else:
33 raise ValueError(str(bit_generator_name) + ' is not a known '
34 'BitGenerator module.')
36 return Generator(bit_generator())
39def __bit_generator_ctor(bit_generator_name='MT19937'):
40 """
41 Pickling helper function that returns a bit generator object
43 Parameters
44 ----------
45 bit_generator_name: str
46 String containing the name of the BitGenerator
48 Returns
49 -------
50 bit_generator: BitGenerator
51 BitGenerator instance
52 """
53 if bit_generator_name in BitGenerators:
54 bit_generator = BitGenerators[bit_generator_name]
55 else:
56 raise ValueError(str(bit_generator_name) + ' is not a known '
57 'BitGenerator module.')
59 return bit_generator()
62def __randomstate_ctor(bit_generator_name='MT19937'):
63 """
64 Pickling helper function that returns a legacy RandomState-like object
66 Parameters
67 ----------
68 bit_generator_name: str
69 String containing the core BitGenerator
71 Returns
72 -------
73 rs: RandomState
74 Legacy RandomState using the named core BitGenerator
75 """
76 if bit_generator_name in BitGenerators:
77 bit_generator = BitGenerators[bit_generator_name]
78 else:
79 raise ValueError(str(bit_generator_name) + ' is not a known '
80 'BitGenerator module.')
82 return RandomState(bit_generator())