1- #!/usr/bin/env python
2- # -*- coding: utf-8 -*-
31"""
4- Copyright (c) 2016-2022 Philippe Schmouker, schmouk (at) gmail.com
2+ Copyright (c) 2016-2025 Philippe Schmouker, schmouk (at) gmail.com
53
64Permission is hereby granted, free of charge, to any person obtaining a copy
75of this software and associated documentation files (the "Software"), to deal
2321"""
2422
2523#=============================================================================
26- from .baserandom import BaseRandom
27- from .fastrand32 import FastRand32
28- from .types import SeedStateType , StateType
24+ from .baserandom import BaseRandom
25+ from .fastrand32 import FastRand32
26+ from .annotation_types import SeedStateType , StateType
2927
3028
3129#=============================================================================
@@ -34,7 +32,7 @@ class BaseMRG( BaseRandom ):
3432
3533 This module is part of library PyRandLib.
3634
37- Copyright (c) 2016-2021 Philippe Schmouker
35+ Copyright (c) 2016-2025 Philippe Schmouker
3836
3937 Multiple Recursive Generators (MRGs) uses recurrence to evaluate pseudo-random
4038 numbers suites. Recurrence is of the form:
@@ -63,15 +61,15 @@ class BaseMRG( BaseRandom ):
6361 Example:
6462
6563 rand = BaseMRG()
66- print( rand() ) # prints a uniform pseudo-random value within [0.0, 1.0)
67- print( rand(a) ) # prints a uniform pseudo-random value within [0.0, a)
68- print( rand(a,b) ) # prints a uniform pseudo-random value within [a , b)
64+ print( rand() ) # prints a pseudo-random value within [0.0, 1.0)
65+ print( rand(a) ) # prints a pseudo-random value within [0.0, a)
66+ print( rand(a,b) ) # prints a pseudo-random value within [a , b)
6967
7068 Inheriting classes have to define class attributes '_LIST_SIZE' and '_MODULO'. See
7169 MRGRand287 for an example.
7270
7371 Reminder:
74- We give you here below a copy of the table of tests for the LCGs that have
72+ We give you here below a copy of the table of tests for the MRGs that have
7573 been implemented in PyRandLib, as provided in paper "TestU01, ..." - see
7674 file README.md.
7775
@@ -105,7 +103,7 @@ def __init__(self, _seedState: SeedStateType = None) -> None:
105103 """
106104 super ().__init__ ( _seedState )
107105 # this call creates the two attributes
108- # self._list and self._index, and sets them
106+ # self._state and self._index, and sets them
109107 # since it internally calls self.setstate().
110108
111109
@@ -128,7 +126,7 @@ def getstate(self) -> StateType:
128126 tuple containing a list of self._LIST_SIZE integers and an
129127 index in this list (index value being then in range(0,self._LIST_SIZE).
130128 """
131- return (self ._list [:], self ._index )
129+ return (self ._state [:], self ._index )
132130
133131
134132 #------------------------------------------------------------------------=
@@ -152,19 +150,19 @@ def setstate(self, _seedState: StateType) -> None:
152150
153151 if count == 0 :
154152 self ._initIndex ( 0 )
155- self ._initList ()
153+ self ._initState ()
156154
157155 elif count == 1 :
158156 self ._initIndex ( 0 )
159- self ._initList ( _seedState [0 ] )
157+ self ._initState ( _seedState [0 ] )
160158
161159 else :
162160 self ._initIndex ( _seedState [1 ] )
163- self ._list = _seedState [0 ][:]
161+ self ._state = _seedState [0 ][:]
164162
165163 except :
166164 self ._initIndex ( 0 )
167- self ._initList ( _seedState )
165+ self ._initState ( _seedState )
168166
169167
170168 #------------------------------------------------------------------------=
@@ -178,7 +176,7 @@ def _initIndex(self, _index: int) -> None:
178176
179177
180178 #------------------------------------------------------------------------=
181- def _initList (self , _initialSeed : StateType = None ) -> None :
179+ def _initState (self , _initialSeed : StateType = None ) -> None :
182180 """Inits the internal list of values.
183181
184182 Inits the internal list of values according to some initial
@@ -188,7 +186,7 @@ def _initList(self, _initialSeed: StateType = None) -> None:
188186 """
189187 # feeds the list according to an initial seed and the value+1 of the modulo.
190188 myRand = FastRand32 ( _initialSeed )
191- self ._list = [ int (myRand (self ._MODULO + 1 )) for _ in range (self ._LIST_SIZE ) ]
189+ self ._state = [ int (myRand (self ._MODULO + 1 )) for _ in range (self ._LIST_SIZE ) ]
192190
193191
194192#===== end of module basemrg.py ========================================
0 commit comments