Skip to content

Commit d41190c

Browse files
committed
#219-fix typos in docstrings
Intermediate commit. Completeed and fully validated on all base classes.
1 parent 5049e99 commit d41190c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+350
-189
lines changed

Python3.10/PyRandLib/basecwg.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ class BaseCWG( BaseRandom ):
5050
See Cwg64 for a minimum 2^70 (i.e. about 1.18e+21) period CW-Generator
5151
with low computation time, medium period, 64- bits output values and very
5252
good randomness characteristics.
53+
5354
See Cwg128_64 for a minimum 2^71 (i.e. about 2.36e+21) period CW-Generator
5455
with very low computation time, medium period, 64-bits output values and
5556
very good randomness characteristics.
57+
5658
See Cwg128 for a minimum 2^135 (i.e. about 4.36e+40) period CW-generator
5759
with very low computation time, medium period, 64- bits output values and
5860
very good randomness characteristics.
@@ -88,22 +90,22 @@ def __init__(self, _seedState: SeedStateType = None, /) -> None: # type: ignore
8890
Should _seedState be None then the local time is used as a seed (with
8991
its shuffled value).
9092
Notice: method setstate() is not implemented in base class BaseRandom.
91-
So, it must be implemented in classes inheriting BaseLCG and it must
93+
So, it must be implemented in classes inheriting BaseCWG and it must
9294
initialize attribute self._state.
9395
"""
9496
super().__init__( _seedState ) # this internally calls 'setstate()' which
9597
# MUST be implemented in inheriting classes
9698

97-
99+
98100
#-------------------------------------------------------------------------
99101
def getstate(self) -> StatesListAndExt:
100102
"""Returns an object capturing the current internal state of the generator.
101103
102-
This object can be passed to setstate() to restore the state.
103-
For CWG, this state is defined by a list of control values
104-
(a, weyl and s - or a list of 4 coeffs) and an internal state
105-
value, which are used in methods 'next() and 'setstate() of
106-
every inheriting class.
104+
This object can be passed to setstate() to restore the state.
105+
For CWG, this state is defined by a list of control values
106+
(a, weyl, s and an internal state value - or a list of 4 coeffs),
107+
which are used in methods 'next() and 'setstate() of every in-
108+
heriting class.
107109
108110
All inheriting classes MUST IMPLEMENT this method.
109111
"""

Python3.10/PyRandLib/baselcg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class BaseLCG( BaseRandom ):
4848
See FastRand32 for a 2^32 (i.e. 4.3e+9) period LC-Generator with very low
4949
computation time but shorter period and worse randomness characteristics
5050
than for FastRand63.
51+
5152
See FastRand63 for a 2^63 (i.e. about 9.2e+18) period LC-Generator with
5253
low computation time also, longer period and quite better randomness
5354
characteristics than for FastRand32.

Python3.10/PyRandLib/baselfib64.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,20 @@ def __init__(self, _stateSize: int, _seedState: SeedStateType = None, /) -> None
133133

134134
#-------------------------------------------------------------------------
135135
def seed(self, _seed: Numerical = None, /) -> None: # type: ignore
136+
"""Initiates the internal state of this pseudo-random generator.
137+
"""
136138
super().seed( _seed )
137139

138140

139141
#-------------------------------------------------------------------------
140142
def setstate(self, _state: StateType = None, /) -> None: # type: ignore
143+
"""Restores the internal state of the generator.
144+
145+
_state should have been obtained from a previous call to getstate().
146+
'setstate()' restores the internal state of the generator to what it
147+
was at the time getstate() was lastly called.
148+
Inheriting classes MUST IMPLEMENT this method.
149+
"""
141150
super().setstate(_state)
142151

143152

Python3.10/PyRandLib/basemrg.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ class BaseMRG( ListIndexState ):
4949
5050
See Mrg287 for a shor t period MR-Generator (2^287, i.e. 2.49e+86) with low
5151
computation time but 256 integers memory consumption.
52+
5253
See Mrg1457 for a longer period MR-Generator (2^1457, i.e. 4.0e+438) and longer
5354
computation time (2^31-1 modulus calculations) but less memory space consumption
5455
(47 integers).
56+
5557
See Mrg49507 for a far longer period (2^49507, i.e. 1.2e+14903) with lower
5658
computation time too (32-bits modulus) but use of more memory space (1597
5759
integers).

Python3.10/PyRandLib/basepcg.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ class BasePCG( BaseRandom ):
3838
3939
x(i) = (a * x(i-1) + c) mod m
4040
41-
PCGs associate to this recurrence a permutation of a subpart o f the bits
42-
of the internal state of the PRNG. The output of PCGs is this permutated
43-
subpart of its internal state, leading to a very large enhancement of the
44-
randomness of these algorithms compared with the LCGs one.
41+
PCGs associate to this recurrence a permutation of a subpart of their
42+
internal state bits. The output of PCGs is this permutated subpart of its
43+
internal state, leading to a very large enhancement of the randomness of
44+
these algorithms compared with the LCGs one.
4545
4646
These PRNGs have been tested with TestU01 and have shown to pass all tests
4747
(Pierre L'Ecuyer and Richard Simard (Universite de Montreal) in 'TestU01:
@@ -110,7 +110,7 @@ def getstate(self) -> int: # type: ignore
110110
"""Returns an object capturing the current internal state of the generator.
111111
112112
This object can be passed to setstate() to restore the state.
113-
For LCG, the state is defined with a single integer, 'self._value',
113+
For PCG, the state is defined with a single integer, 'self._value',
114114
which has to be used in methods 'random() and 'setstate() of every
115115
inheriting class.
116116
"""

Python3.10/PyRandLib/baserandom.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class BaseRandom( Random ):
6969
computation time (2^31-1 modulus calculations) but less memory space consumption
7070
(32-bits 47 integers).
7171
See Mrg49507 for a far larger period MR-Generator (2^49507, i.e. 1.2e+14903) with
72-
low computation time too (31-bits modulus) but us of more memory space (1597
72+
low computation time too (31-bits modulus) but use of more memory space (1597
7373
32-bits integers).
7474
7575
See Pcg64_32, Pcg128_64 and Pcg1024_32 for Permuted Congruential Generators with
@@ -97,8 +97,7 @@ class BaseRandom( Random ):
9797
See Xoroshiro256, Xoroshiro512, Xoroshiro1024 for long period generators (resp.
9898
2^256, 2^512 and 2^1024 periods, i.e. resp. 1.16e+77, 1.34e+154 and 1.80e+308
9999
periods), 64-bits precision calculations and short memory consumption (resp. 4,
100-
8 and 16 integers coded on 64 bits.
101-
100+
8 and 16 integers each coded on 64 bits.
102101
103102
Python built-in class random.Random is subclassed here to use a different basic
104103
generator of our own devising: in that case, overriden methods are:
@@ -137,8 +136,6 @@ class BaseRandom( Random ):
137136
| Binomial distribution. Return the number of successes for n
138137
| independent trials with the probability of success in each
139138
| trial being p.
140-
| Notice: added since Python 3.12, implemented in PyRandLib
141-
| for all previous versions of Python.
142139
| n >= 0, 0.0 <= p <= 1.0,
143140
| the result is an integer in the range 0 <= X <= n.
144141
|
@@ -233,16 +230,11 @@ class BaseRandom( Random ):
233230
| large population: sample(range(10000000), 60)
234231
|
235232
|
236-
| seed(self, a=None, version=2)
233+
| seed(self, a=None)
237234
| Initialize internal state from hashable object.
238235
|
239236
| None or no argument seeds from current time or from an operating
240237
| system specific randomness source if available.
241-
|
242-
| For version 2 (the default), all of the bits are used if *a *is a str,
243-
| bytes, or bytearray. For version 1, the hash() of *a* is used instead.
244-
|
245-
| If *a* is an int, all bits are used.
246238
|
247239
|
248240
| setstate(self, state)

Python3.10/PyRandLib/basewell.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,24 @@ class BaseWELL( ListIndexState ):
5050
zeroland.
5151
5252
Notice: the algorithm in the 4 different versions implemented here has been coded
53-
here as a direct implementation of their descriptions in the initial paper
54-
"Improved Long-Period Generators Based on Linear Recurrences Modulo 2", François
55-
PANNETON and Pierre LECUYER (Université de Montréal) and Makoto MATSUMOTO
56-
(Hiroshima University), in ACM Transactions on Mathematical Software, Vol. 32,
57-
No. 1, March 2006, Pages 116.
53+
as a direct implementation of their descriptions in the initial paper "Improved
54+
Long-Period Generators Based on Linear Recurrences Modulo 2", François PANNETON
55+
and Pierre L'ECUYER (Université de Montréal) and Makoto MATSUMOTO (Hiroshima
56+
University), in ACM Transactions on Mathematical Software, Vol. 32, No. 1, March
57+
2006, Pages 1-16.
5858
(see https://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng.pdf).
5959
So, only minimalist optimization has been coded, with the aim at easing the
6060
verification of its proper implementation.
6161
6262
See Well512a for a large period WELL-Generator (2^512, i.e. 1.34e+154) with low
6363
computation time and 16 integers memory little consumption.
64+
6465
See Well1024a for a longer period WELL-Generator (2^1024, i.e. 2.68e+308), same
6566
computation time and 32 integers memory consumption.
66-
See Well199937b for a far longer period (2^19937, i.e. 4.32e+6001) with similar
67+
68+
See Well199937c for a far longer period (2^19937, i.e. 4.32e+6001) with similar
6769
computation time but use of more memory space (624 integers).
68-
See Well44497b for a very large period (2^44497, i.e. 15.1e+13466) with similar
69-
computation time but use of even more memory space (1,391 integers).
70-
70+
7171
Please notice that this class and all its inheriting sub-classes are callable.
7272
Example:
7373
@@ -129,11 +129,20 @@ def __init__(self, _stateSize: int, _seedState: SeedStateType = None, /) -> None
129129

130130
#-------------------------------------------------------------------------
131131
def seed(self, _seed: Numerical = None, /) -> None: # type: ignore
132+
"""Initiates the internal state of this pseudo-random generator.
133+
"""
132134
super().seed( _seed )
133135

134136

135137
#-------------------------------------------------------------------------
136138
def setstate(self, _state: StateType = None, /) -> None: # type: ignore
139+
"""Restores the internal state of the generator.
140+
141+
_state should have been obtained from a previous call to getstate().
142+
'setstate()' restores the internal state of the generator to what it
143+
was at the time getstate() was lastly called.
144+
Inheriting classes MUST IMPLEMENT this method.
145+
"""
137146
super().setstate(_state)
138147

139148

Python3.10/PyRandLib/basexoroshiro.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,20 @@ def __init__(self, _stateSize: int, _seedState: Numerical | StatesList = None, /
132132

133133
#-------------------------------------------------------------------------
134134
def seed(self, _seed: Numerical = None, /) -> None: # type: ignore
135+
"""Initiates the internal state of this pseudo-random generator.
136+
"""
135137
super().seed( _seed )
136138

137139

138140
#-------------------------------------------------------------------------
139141
def setstate(self, _state: StatesList = None, /) -> None: # type: ignore
142+
"""Restores the internal state of the generator.
143+
144+
_state should have been obtained from a previous call to getstate().
145+
'setstate()' restores the internal state of the generator to what it
146+
was at the time getstate() was lastly called.
147+
Inheriting classes MUST IMPLEMENT this method.
148+
"""
140149
super().setstate(_state)
141150

142151

Python3.11/PyRandLib/basecwg.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ class BaseCWG( BaseRandom ):
5050
See Cwg64 for a minimum 2^70 (i.e. about 1.18e+21) period CW-Generator
5151
with low computation time, medium period, 64- bits output values and very
5252
good randomness characteristics.
53+
5354
See Cwg128_64 for a minimum 2^71 (i.e. about 2.36e+21) period CW-Generator
5455
with very low computation time, medium period, 64-bits output values and
5556
very good randomness characteristics.
57+
5658
See Cwg128 for a minimum 2^135 (i.e. about 4.36e+40) period CW-generator
5759
with very low computation time, medium period, 64- bits output values and
5860
very good randomness characteristics.
@@ -88,22 +90,22 @@ def __init__(self, _seedState: SeedStateType = None, /) -> None: # type: ignore
8890
Should _seedState be None then the local time is used as a seed (with
8991
its shuffled value).
9092
Notice: method setstate() is not implemented in base class BaseRandom.
91-
So, it must be implemented in classes inheriting BaseLCG and it must
93+
So, it must be implemented in classes inheriting BaseCWG and it must
9294
initialize attribute self._state.
9395
"""
9496
super().__init__( _seedState ) # this internally calls 'setstate()' which
9597
# MUST be implemented in inheriting classes
9698

97-
99+
98100
#-------------------------------------------------------------------------
99101
def getstate(self) -> StatesListAndExt:
100102
"""Returns an object capturing the current internal state of the generator.
101103
102-
This object can be passed to setstate() to restore the state.
103-
For CWG, this state is defined by a list of control values
104-
(a, weyl and s - or a list of 4 coeffs) and an internal state
105-
value, which are used in methods 'next() and 'setstate() of
106-
every inheriting class.
104+
This object can be passed to setstate() to restore the state.
105+
For CWG, this state is defined by a list of control values
106+
(a, weyl, s and an internal state value - or a list of 4 coeffs),
107+
which are used in methods 'next() and 'setstate() of every in-
108+
heriting class.
107109
108110
All inheriting classes MUST IMPLEMENT this method.
109111
"""

Python3.11/PyRandLib/baselcg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class BaseLCG( BaseRandom ):
4848
See FastRand32 for a 2^32 (i.e. 4.3e+9) period LC-Generator with very low
4949
computation time but shorter period and worse randomness characteristics
5050
than for FastRand63.
51+
5152
See FastRand63 for a 2^63 (i.e. about 9.2e+18) period LC-Generator with
5253
low computation time also, longer period and quite better randomness
5354
characteristics than for FastRand32.

0 commit comments

Comments
 (0)