Skip to content

Commit de0ecf4

Browse files
committed
Code conforms now with Python PEP 484 -- Type Hints
This is a minor release.
1 parent f4f6dae commit de0ecf4

13 files changed

+32
-32
lines changed

PyRandLib/baselcg.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class BaseLCG( BaseRandom ):
7979
"""
8080

8181
#=========================================================================
82-
def __init__(self, _seedState=None):
82+
def __init__(self, _seedState: int = None) -> None:
8383
"""
8484
Constructor. Should inSeed be None or not an integer then
8585
the local time is used (with its shuffled value) as a seed.
@@ -88,7 +88,7 @@ def __init__(self, _seedState=None):
8888

8989

9090
#=========================================================================
91-
def random(self):
91+
def random(self) -> float:
9292
"""
9393
This is the core of the pseudo-random generator.
9494
Returned values are within [0.0, 1.0).
@@ -99,7 +99,7 @@ def random(self):
9999

100100

101101
#=========================================================================
102-
def getstate(self):
102+
def getstate(self) -> int:
103103
"""
104104
Returns an object capturing the current internal state of the generator.
105105
This object can be passed to setstate() to restore the state.
@@ -111,7 +111,7 @@ def getstate(self):
111111

112112

113113
#=========================================================================
114-
def setstate(self, _state):
114+
def setstate(self, _state: int) -> None:
115115
"""
116116
_state should have been obtained from a previous call to getstate(),
117117
and setstate() restores the internal state of the generator to what

PyRandLib/baselfib64.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class BaseLFib64( BaseRandom ):
9393
"""
9494

9595
#=========================================================================
96-
def __init__(self, _seedState=None):
96+
def __init__(self, _seedState: tuple = None) -> None:
9797
"""
9898
Constructor.
9999
_seedState is either a valid state, an integer, a float or None.
@@ -113,7 +113,7 @@ def __init__(self, _seedState=None):
113113

114114

115115
#=========================================================================
116-
def random(self):
116+
def random(self) -> float:
117117
"""
118118
This is the core of the pseudo-random generator.
119119
Returned values are within [0.0, 1.0).
@@ -124,7 +124,7 @@ def random(self):
124124

125125

126126
#=========================================================================
127-
def getstate(self):
127+
def getstate(self) -> tuple:
128128
"""
129129
Return an object capturing the current internal state of the generator.
130130
This object can be passed to setstate() to restore the state. It is a
@@ -135,7 +135,7 @@ def getstate(self):
135135

136136

137137
#=========================================================================
138-
def setstate(self, _seedState):
138+
def setstate(self, _seedState: tuple) -> None:
139139
"""
140140
_seedState should have been obtained from a previous call to
141141
getstate(), and setstate() restores the internal state of the
@@ -163,7 +163,7 @@ def setstate(self, _seedState):
163163

164164

165165
#=========================================================================
166-
def _initIndex(self, _index):
166+
def _initIndex(self, _index: int) -> None:
167167
"""
168168
Inits the internal index pointing to the internal list.
169169
"""
@@ -174,7 +174,7 @@ def _initIndex(self, _index):
174174

175175

176176
#=========================================================================
177-
def _initList(self, _initialSeed=None):
177+
def _initList(self, _initialSeed: list = None) -> None:
178178
"""
179179
Inits the internal list of values according to some initial
180180
seed that has to be an integer or a float ranging within

PyRandLib/basemrg.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class BaseMRG( BaseRandom ):
9090
"""
9191

9292
#=========================================================================
93-
def __init__(self, _seedState=None):
93+
def __init__(self, _seedState: (int,float,list) = None) -> None:
9494
"""
9595
Constructor.
9696
_seedState is either a valid state, an integer, a float or None.
@@ -110,7 +110,7 @@ def __init__(self, _seedState=None):
110110

111111

112112
#=========================================================================
113-
def random(self):
113+
def random(self) -> float:
114114
"""
115115
This is the core of the pseudo-random generator.
116116
Returned values are within [0.0, 1.0).
@@ -121,7 +121,7 @@ def random(self):
121121

122122

123123
#=========================================================================
124-
def getstate(self):
124+
def getstate(self) -> tuple:
125125
"""
126126
Return an object capturing the current internal state of the generator.
127127
This object can be passed to setstate() to restore the state. It is a
@@ -132,7 +132,7 @@ def getstate(self):
132132

133133

134134
#=========================================================================
135-
def setstate(self, _seedState):
135+
def setstate(self, _seedState: tuple) -> None:
136136
"""
137137
_seedState should have been obtained from a previous call to
138138
getstate(), and setstate() restores the internal state of the
@@ -160,7 +160,7 @@ def setstate(self, _seedState):
160160

161161

162162
#=========================================================================
163-
def _initIndex(self, _index):
163+
def _initIndex(self, _index: int) -> None:
164164
"""
165165
Inits the internal index pointing to the internal list.
166166
"""
@@ -171,7 +171,7 @@ def _initIndex(self, _index):
171171

172172

173173
#=========================================================================
174-
def _initList(self, _initialSeed=None):
174+
def _initList(self, _initialSeed: list = None) -> None:
175175
"""
176176
Inits the internal list of values according to some initial
177177
seed that has to be an integer or a float ranging within

PyRandLib/baserandom.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class BaseRandom( Random ):
213213
"""
214214

215215
#=========================================================================
216-
def __init__(self, _seed=None):
216+
def __init__(self, _seed: (int,float,list) = None) -> None:
217217
"""
218218
Constructor. Should _seed be None or not an integer then the
219219
local time is used (with its shuffled value) as a seed.
@@ -222,7 +222,7 @@ def __init__(self, _seed=None):
222222

223223

224224
#=========================================================================
225-
def seed(self, _seed=None):
225+
def seed(self, _seed: (int,float,list) = None) -> None:
226226
"""
227227
Initiates the internal state of this pseudo-random generator.
228228
"""
@@ -233,7 +233,7 @@ def seed(self, _seed=None):
233233

234234

235235
#=========================================================================
236-
def __call__(self, _max=1.0):
236+
def __call__(self, _max: (int,float) = 1.0) -> float:
237237
"""
238238
This class's instances are callable. The returned value is uniformly
239239
contained within the interval [0.0 : _max].

PyRandLib/fastrand32.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ class FastRand32( BaseLCG ):
9292
"""
9393

9494
#=========================================================================
95-
def __init__(self, _seed=None):
95+
def __init__(self, _seed: (int,float) = None) -> None:
9696
"""
97-
Constructor. Should _seed be None or not an integer then
97+
Constructor. Should _seed be None or not a numeric then
9898
the local time is used (with its shuffled value) as a seed.
9999
"""
100100
super().__init__( _seed ) # this call creates attribute self._value and sets it
101101

102102

103103
#=========================================================================
104-
def random(self):
104+
def random(self) -> float:
105105
"""
106106
This is the core of the pseudo-random generator.
107107
Returned values are within [0.0, 1.0).
@@ -111,7 +111,7 @@ def random(self):
111111

112112

113113
#=========================================================================
114-
def setstate(self, _state):
114+
def setstate(self, _state: (int,float)) -> None:
115115
"""
116116
_state should have been obtained from a previous call to getstate(),
117117
and setstate() restores the internal state of the generator to what

PyRandLib/fastrand63.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class FastRand63( BaseLCG ):
9292
"""
9393

9494
#=========================================================================
95-
def random(self):
95+
def random(self) -> float:
9696
"""
9797
This is the core of the pseudo-random generator.
9898
Returned values are within [0.0, 1.0).
@@ -102,7 +102,7 @@ def random(self):
102102

103103

104104
#=========================================================================
105-
def setstate(self, _state):
105+
def setstate(self, _state:(int,float)) -> None:
106106
"""
107107
_state should have been obtained from a previous call to getstate(),
108108
and setstate() restores the internal state of the generator to what

PyRandLib/lfib116.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class LFib116( BaseLFib64 ):
116116

117117

118118
#=========================================================================
119-
def random(self):
119+
def random(self) -> float:
120120
"""
121121
This is the core of the pseudo-random generator.
122122
Returned values are within [0.0, 1.0).

PyRandLib/lfib1340.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class LFib1340( BaseLFib64 ):
117117

118118

119119
#=========================================================================
120-
def random(self):
120+
def random(self) -> float:
121121
"""
122122
This is the core of the pseudo-random generator.
123123
Returned values are within [0.0, 1.0).

PyRandLib/lfib668.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class LFib668( BaseLFib64 ):
116116

117117

118118
#=========================================================================
119-
def random(self):
119+
def random(self) -> float:
120120
"""
121121
This is the core of the pseudo-random generator.
122122
Returned values are within [0.0, 1.0).

PyRandLib/lfib78.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class LFib78( BaseLFib64 ):
115115

116116

117117
#=========================================================================
118-
def random(self):
118+
def random(self) -> float:
119119
"""
120120
This is the core of the pseudo-random generator.
121121
Returned values are within [0.0, 1.0).

0 commit comments

Comments
 (0)