Skip to content

Commit c8953d4

Browse files
committed
#223-remove Pylance warnings
Still to be validated.
1 parent b028064 commit c8953d4

24 files changed

+702
-683
lines changed

Python3.10/unit_tests/test_basecwg.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ class TestBaseCwg:
3434
#-------------------------------------------------------------------------
3535
def test_init_empty(self):
3636
b_cwg = BaseCWG()
37-
assert b_cwg.gauss_next is None
37+
assert b_cwg.gauss_next is None # type: ignore
3838

3939
#-------------------------------------------------------------------------
4040
def test_init_int(self):
4141
b_cwg = BaseCWG(0X1234_5678_9abc_def0)
42-
assert b_cwg.gauss_next is None
42+
assert b_cwg.gauss_next is None # type: ignore
4343

4444
#-------------------------------------------------------------------------
4545
def test_init_float(self):
4646
b_cwg = BaseCWG(0.1)
47-
assert b_cwg.gauss_next is None
47+
assert b_cwg.gauss_next is None # type: ignore
4848

4949
#-------------------------------------------------------------------------
5050
def test_init_tuple(self):
5151
with pytest.raises(NotImplementedError):
52-
b_cwg = BaseCWG((0, 1, 0X1234_5678_9abc_def0, 0X1234_5678_9abc_def0))
52+
b_cwg = BaseCWG((0, 1, 0X1234_5678_9abc_def0, 0X1234_5678_9abc_def0)) # type: ignore
5353

5454
#-------------------------------------------------------------------------
5555
def test_init_list(self):
@@ -59,7 +59,7 @@ def test_init_list(self):
5959
#-------------------------------------------------------------------------
6060
def test_init_tuple_int(self):
6161
with pytest.raises(NotImplementedError):
62-
b_cwg = BaseCWG( ((0, 1, 0X1234_5678_9abc_def0, 0X1234_5678_9abc_def0), 11) )
62+
b_cwg = BaseCWG( ((0, 1, 0X1234_5678_9abc_def0, 0X1234_5678_9abc_def0), 11) ) # type: ignore
6363

6464
#-------------------------------------------------------------------------
6565
def test_init_list_int(self):
@@ -70,4 +70,4 @@ def test_init_list_int(self):
7070
def test_getstate(self):
7171
b_cwg = BaseCWG()
7272
with pytest.raises(AttributeError):
73-
a, weyl, s, state = b_cwg.getstate()
73+
a, weyl, s, state = b_cwg.getstate() # type: ignore

Python3.10/unit_tests/test_baselcg.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,52 +28,53 @@
2828

2929
#=============================================================================
3030
class TestBaseLcg:
31-
"""Tests the base class BaseLCG"""
31+
"""Tests the base class BaseLCG.
32+
"""
3233

3334
#-------------------------------------------------------------------------
3435
def test_init_empty(self):
3536
b_lcg = BaseLCG()
36-
assert b_lcg.gauss_next is None
37+
assert b_lcg.gauss_next is None # type: ignore
3738

3839
#-------------------------------------------------------------------------
3940
def test_init_int(self):
4041
b_lcg = BaseLCG(0X1234_5678_9abc_def0)
41-
assert b_lcg.gauss_next is None
42+
assert b_lcg.gauss_next is None # type: ignore
4243

4344
#-------------------------------------------------------------------------
4445
def test_init_float(self):
4546
b_lcg = BaseLCG(0.1)
46-
assert b_lcg.gauss_next is None
47+
assert b_lcg.gauss_next is None # type: ignore
4748

4849
#-------------------------------------------------------------------------
4950
def test_init_tuple(self):
5051
with pytest.raises(NotImplementedError):
51-
b_lcg = BaseLCG((0, 1, 0X1234_5678_9abc_def0, 0X1234_5678_9abc_def0))
52+
b_lcg = BaseLCG((0, 1, 0X1234_5678_9abc_def0, 0X1234_5678_9abc_def0)) # type: ignore
5253

5354
#-------------------------------------------------------------------------
5455
def test_init_list(self):
5556
with pytest.raises(TypeError): # notice: TypeError here due to a known bug with unhashable lists in Python 3.10
56-
b_lcg = BaseLCG([0, 1, 0X1234_5678_9abc_def0, 0X1234_5678_9abc_def0])
57+
b_lcg = BaseLCG([0, 1, 0X1234_5678_9abc_def0, 0X1234_5678_9abc_def0]) # type: ignore
5758

5859
#-------------------------------------------------------------------------
5960
def test_init_tuple_int(self):
6061
with pytest.raises(NotImplementedError):
61-
b_lcg = BaseLCG( ((0, 1, 0X1234_5678_9abc_def0, 0X1234_5678_9abc_def0), 11) )
62+
b_lcg = BaseLCG( ((0, 1, 0X1234_5678_9abc_def0, 0X1234_5678_9abc_def0), 11) ) # type: ignore
6263

6364
#-------------------------------------------------------------------------
6465
def test_init_list_int(self):
6566
with pytest.raises(TypeError): # notice: TypeError here due to a known bug with unhashable lists in Python 3.10
66-
b_lcg = BaseLCG( ([0, 1, 0X1234_5678_9abc_def0, 0X1234_5678_9abc_def0], 11))
67+
b_lcg = BaseLCG( ([0, 1, 0X1234_5678_9abc_def0, 0X1234_5678_9abc_def0], 11)) # type: ignore
6768

6869
#-------------------------------------------------------------------------
6970
def test_init_tuple_int_2(self):
7071
with pytest.raises(TypeError): # notice: TypeError here due to a known bug with unhashable lists in Python 3.10
71-
b_lcg = BaseLCG( [(0, 1, 0X1234_5678_9abc_def0, 0X1234_5678_9abc_def0), 11] )
72+
b_lcg = BaseLCG( [(0, 1, 0X1234_5678_9abc_def0, 0X1234_5678_9abc_def0), 11] ) # type: ignore
7273

7374
#-------------------------------------------------------------------------
7475
def test_init_list_int_2(self):
7576
with pytest.raises(TypeError): # notice: TypeError here due to a known bug with unhashable lists in Python 3.10
76-
b_lcg = BaseLCG( [[0, 1, 0X1234_5678_9abc_def0, 0X1234_5678_9abc_def0], 11] )
77+
b_lcg = BaseLCG( [[0, 1, 0X1234_5678_9abc_def0, 0X1234_5678_9abc_def0], 11] ) # type: ignore
7778

7879
#-------------------------------------------------------------------------
7980
def test_getstate(self):

Python3.10/unit_tests/test_baselfib64.py

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030
#=============================================================================
3131
class TestBaseLFib64:
32-
"""Tests the base class BaseLFib64"""
32+
"""Tests the base class BaseLFib64.
33+
"""
3334

3435
#-------------------------------------------------------------------------
3536
def test_class_BaseLFib64(self):
@@ -42,10 +43,10 @@ def test_init_empty(self):
4243
b_lfib = BaseLFib64(STATE_SIZE)
4344
assert b_lfib._STATE_SIZE == STATE_SIZE
4445
assert b_lfib._initRandClass is SplitMix64
45-
assert b_lfib.gauss_next is None
46+
assert b_lfib.gauss_next is None # type: ignore
4647
assert b_lfib._index == 0
4748
assert len( b_lfib._state ) == STATE_SIZE
48-
assert all( s != 0 for s in b_lfib._state )
49+
assert all( 0 < s <= (1 << 64) for s in b_lfib._state ) # type: ignore
4950

5051
#-------------------------------------------------------------------------
5152
def test_init_int(self):
@@ -54,10 +55,10 @@ def test_init_int(self):
5455
b_lfib = BaseLFib64(STATE_SIZE, 0X1234_5678_9abc_def0)
5556
assert b_lfib._STATE_SIZE == STATE_SIZE
5657
assert b_lfib._initRandClass is SplitMix64
57-
assert b_lfib.gauss_next is None
58+
assert b_lfib.gauss_next is None # type: ignore
5859
assert b_lfib._index == 0
5960
assert len( b_lfib._state ) == STATE_SIZE
60-
assert all( s != 0 for s in b_lfib._state )
61+
assert all( 0 < s <= (1 << 64) for s in b_lfib._state ) # type: ignore
6162

6263
#-------------------------------------------------------------------------
6364
def test_init_float(self):
@@ -66,22 +67,22 @@ def test_init_float(self):
6667
b_lfib = BaseLFib64(STATE_SIZE, 0.1)
6768
assert b_lfib._STATE_SIZE == STATE_SIZE
6869
assert b_lfib._initRandClass is SplitMix64
69-
assert b_lfib.gauss_next is None
70+
assert b_lfib.gauss_next is None # type: ignore
7071
assert b_lfib._index == 0
7172
assert len( b_lfib._state ) == STATE_SIZE
72-
assert all( s != 0 for s in b_lfib._state )
73+
assert all( 0 < s <= (1 << 64) for s in b_lfib._state ) # type: ignore
7374

7475
#-------------------------------------------------------------------------
7576
def test_init_tuple(self):
7677
STATE_SIZE = 19
7778
with pytest.raises(TypeError): # notice: no 2 arguments allowed in random.Random with Python 3.10
78-
b_lfib = BaseLFib64(STATE_SIZE, tuple(i+1 for i in range(STATE_SIZE)))
79+
b_lfib = BaseLFib64(STATE_SIZE, tuple(i+1 for i in range(STATE_SIZE))) # type: ignore
7980
assert b_lfib._STATE_SIZE == STATE_SIZE
8081
assert b_lfib._initRandClass is SplitMix64
81-
assert b_lfib.gauss_next is None
82+
assert b_lfib.gauss_next is None # type: ignore
8283
assert b_lfib._index == 0
8384
assert len( b_lfib._state ) == STATE_SIZE
84-
assert all( s != 0 for s in b_lfib._state )
85+
assert all( 0 < s <= (1 << 64) for s in b_lfib._state ) # type: ignore
8586

8687
#-------------------------------------------------------------------------
8788
def test_init_list(self):
@@ -90,152 +91,152 @@ def test_init_list(self):
9091
b_lfib = BaseLFib64(STATE_SIZE, [i+1 for i in range(STATE_SIZE)])
9192
assert b_lfib._STATE_SIZE == STATE_SIZE
9293
assert b_lfib._initRandClass is SplitMix64
93-
assert b_lfib.gauss_next is None
94+
assert b_lfib.gauss_next is None # type: ignore
9495
assert b_lfib._index == 0
9596
assert len( b_lfib._state ) == STATE_SIZE
96-
assert all( s != 0 for s in b_lfib._state )
97+
assert all( 0 < s <= (1 << 64) for s in b_lfib._state ) # type: ignore
9798

9899
#-------------------------------------------------------------------------
99100
def test_init_tuple_int(self):
100101
STATE_SIZE = 23
101102
with pytest.raises(TypeError):
102103
# notice: no 2 arguments accepted in tuple with base class random.Random constructor since Python 3.11
103-
b_lfib = BaseLFib64(STATE_SIZE, tuple(STATE_SIZE-1, tuple(i+1 for i in range(STATE_SIZE))))
104+
b_lfib = BaseLFib64(STATE_SIZE, tuple(STATE_SIZE-1, tuple(i+1 for i in range(STATE_SIZE)))) # type: ignore
104105

105106
#-------------------------------------------------------------------------
106107
def test_init_list_int(self):
107108
STATE_SIZE = 25
108109
with pytest.raises(TypeError):
109110
# notice: no 2 arguments accepted in tuple with base class random.Random constructor since Python 3.11
110-
b_lfib = BaseLFib64( STATE_SIZE, tuple(STATE_SIZE-1, [i+1 for i in range(STATE_SIZE)]) )
111+
b_lfib = BaseLFib64( STATE_SIZE, tuple(STATE_SIZE-1, [i+1 for i in range(STATE_SIZE)]) ) # type: ignore
111112

112113
#-------------------------------------------------------------------------
113114
def test_seed(self):
114115
b_lfib = BaseLFib64(5)
115116
assert b_lfib._STATE_SIZE == 5
116117
assert b_lfib._initRandClass is SplitMix64
117-
assert b_lfib.gauss_next is None
118+
assert b_lfib.gauss_next is None # type: ignore
118119
assert b_lfib._index == 0
119120
assert len(b_lfib._state) == 5
120-
assert all(s != 0 for s in b_lfib._state)
121+
assert all( 0 < s <= (1 << 64) for s in b_lfib._state ) # type: ignore
121122

122123
b_lfib.seed(-1)
123124
assert b_lfib._state == [0xe4d971771b652c20, 0xe99ff867dbf682c9, 0x382ff84cb27281e9, 0x6d1db36ccba982d2, 0xb4a0472e578069ae]
124-
assert b_lfib.gauss_next is None
125+
assert b_lfib.gauss_next is None # type: ignore
125126
assert b_lfib._index == 0
126127

127128
b_lfib.seed(28031)
128129
assert b_lfib._state == [0x2705aecd4f8c9690, 0x72100965d36abc80, 0x663e44c5f050c8fb, 0x975621c9151333a5, 0xc269b7b2092500b7]
129-
assert b_lfib.gauss_next is None
130+
assert b_lfib.gauss_next is None # type: ignore
130131
assert b_lfib._index == 0
131132

132133
b_lfib.seed(0xffff_ffff_ffff_ffff)
133134
assert b_lfib._state == [0xe4d971771b652c20, 0xe99ff867dbf682c9, 0x382ff84cb27281e9, 0x6d1db36ccba982d2, 0xb4a0472e578069ae]
134-
assert b_lfib.gauss_next is None
135+
assert b_lfib.gauss_next is None # type: ignore
135136
assert b_lfib._index == 0
136137

137138
b_lfib.seed(0.187)
138139
assert b_lfib._state == [0x2b18160c0a9f05b4, 0xc8197d13a4d6d45f, 0xaca007e67e920ed1, 0xf0e779fe3279121f, 0xcd551efd3099f223]
139-
assert b_lfib.gauss_next is None
140+
assert b_lfib.gauss_next is None # type: ignore
140141
assert b_lfib._index == 0
141142

142143
b_lfib.seed(0xffff_ffff_ffff_fffe_ffff_ffff_ffff_fffd)
143144
assert b_lfib._state == [0xf75f04cbb5a1a1dd, 0xec779c3693f88501, 0xfed9eeb4936de39d, 0x6f9fb04b092bd30a, 0x260ffb0260bbbe5f]
144-
assert b_lfib.gauss_next is None
145+
assert b_lfib.gauss_next is None # type: ignore
145146
assert b_lfib._index == 0
146147

147148
with pytest.raises(TypeError):
148-
b_lfib.seed((1, 2, 3, 4, 5))
149+
b_lfib.seed((1, 2, 3, 4, 5)) # type: ignore
149150
assert b_lfib._state == [1, 2, 3, 4, 5]
150-
assert b_lfib.gauss_next is None
151+
assert b_lfib.gauss_next is None # type: ignore
151152
assert b_lfib._index == 0
152153

153154
with pytest.raises(TypeError):
154-
b_lfib.seed([11, 12, 13, 14, 15])
155+
b_lfib.seed([11, 12, 13, 14, 15]) # type: ignore
155156
assert b_lfib._state == [11, 12, 13, 14, 15]
156-
assert b_lfib.gauss_next is None
157+
assert b_lfib.gauss_next is None # type: ignore
157158
assert b_lfib._index == 0
158159

159160
with pytest.raises(TypeError):
160-
b_lfib.seed([[31, 32, 33, 34, 35], 2])
161+
b_lfib.seed([[31, 32, 33, 34, 35], 2]) # type: ignore
161162
assert b_lfib._state == [31, 32, 33, 34, 35]
162-
assert b_lfib.gauss_next is None
163+
assert b_lfib.gauss_next is None # type: ignore
163164
assert b_lfib._index == 2
164165

165166
with pytest.raises(TypeError):
166-
b_lfib.seed(((21, 22, 23, 24, 25), 3))
167+
b_lfib.seed(((21, 22, 23, 24, 25), 3)) # type: ignore
167168
assert b_lfib._state == [21, 22, 23, 24, 25]
168-
assert b_lfib.gauss_next is None
169+
assert b_lfib.gauss_next is None # type: ignore
169170
assert b_lfib._index == 3
170171

171172
with pytest.raises(ValueError):
172173
b_lfib.seed(8.87e+18)
173174
with pytest.raises(ValueError):
174175
b_lfib.seed(-0.987)
175176
with pytest.raises(TypeError):
176-
b_lfib.seed([[31, 32, 33, 34, 35.1], 1])
177+
b_lfib.seed([[31, 32, 33, 34, 35.1], 1]) # type: ignore
177178
with pytest.raises(TypeError):
178-
b_lfib.seed((31, 32, 33, 34, 35.1))
179+
b_lfib.seed((31, 32, 33, 34, 35.1)) # type: ignore
179180

180181
#-------------------------------------------------------------------------
181182
def test_setstate(self):
182183
b_lfib = BaseLFib64(5)
183184

184185
with pytest.raises(TypeError):
185-
b_lfib.setstate(-1)
186+
b_lfib.setstate(-1) # type: ignore
186187

187188
with pytest.raises(TypeError):
188-
b_lfib.setstate(28031)
189+
b_lfib.setstate(28031) # type: ignore
189190

190191
with pytest.raises(TypeError):
191-
b_lfib.setstate(0xffff_ffff_ffff_ffff)
192+
b_lfib.setstate(0xffff_ffff_ffff_ffff) # type: ignore
192193

193194
with pytest.raises(TypeError):
194-
b_lfib.setstate(0.187)
195+
b_lfib.setstate(0.187) # type: ignore
195196

196197
with pytest.raises(TypeError):
197-
b_lfib.setstate(0xffff_ffff_ffff_fffe_ffff_ffff_ffff_fffd)
198+
b_lfib.setstate(0xffff_ffff_ffff_fffe_ffff_ffff_ffff_fffd) # type: ignore
198199

199-
b_lfib.setstate((1, 2, 3, 4, 5))
200+
b_lfib.setstate((1, 2, 3, 4, 5)) # type: ignore
200201
assert b_lfib._state == [1, 2, 3, 4, 5]
201-
assert b_lfib.gauss_next is None
202+
assert b_lfib.gauss_next is None # type: ignore
202203
assert b_lfib._index == 0
203204

204205
b_lfib.setstate([11, 12, 13, 14, 15])
205206
assert b_lfib._state == [11, 12, 13, 14, 15]
206-
assert b_lfib.gauss_next is None
207+
assert b_lfib.gauss_next is None # type: ignore
207208
assert b_lfib._index == 0
208209

209-
b_lfib.setstate([[31, 32, 33, 34, 35], 2])
210+
b_lfib.setstate([[31, 32, 33, 34, 35], 2]) # type: ignore
210211
assert b_lfib._state == [31, 32, 33, 34, 35]
211-
assert b_lfib.gauss_next is None
212+
assert b_lfib.gauss_next is None # type: ignore
212213
assert b_lfib._index == 2
213214

214-
b_lfib.setstate(((21, 22, 23, 24, 25), 3))
215+
b_lfib.setstate(((21, 22, 23, 24, 25), 3)) # type: ignore
215216
assert b_lfib._state == [21, 22, 23, 24, 25]
216-
assert b_lfib.gauss_next is None
217+
assert b_lfib.gauss_next is None # type: ignore
217218
assert b_lfib._index == 3
218219

219220
with pytest.raises(TypeError):
220-
b_lfib.setstate(8.87e+18)
221+
b_lfib.setstate(8.87e+18) # type: ignore
221222
with pytest.raises(TypeError):
222-
b_lfib.setstate(-0.987)
223+
b_lfib.setstate(-0.987) # type: ignore
223224

224225
with pytest.raises(ValueError):
225-
b_lfib.setstate([31, 32, 33.5, 34, 35.1])
226+
b_lfib.setstate([31, 32, 33.5, 34, 35.1]) # type: ignore
226227
with pytest.raises(ValueError):
227-
b_lfib.setstate((31, 32.6, 33, 34, 35.1))
228+
b_lfib.setstate((31, 32.6, 33, 34, 35.1)) # type: ignore
228229

229230
with pytest.raises(ValueError):
230231
b_lfib.setstate([-31, 32, 33, 34, -35])
231232
with pytest.raises(ValueError):
232-
b_lfib.setstate((31, -32, 33, 34, 35))
233+
b_lfib.setstate((31, -32, 33, 34, 35)) # type: ignore
233234

234235
with pytest.raises(ValueError):
235-
b_lfib.setstate([[31, 32, 33, 34, 35.1], 1])
236+
b_lfib.setstate([[31, 32, 33, 34, 35.1], 1]) # type: ignore
236237
with pytest.raises(ValueError):
237238
b_lfib.setstate(([31, 32, 33, 34.0, 35.1], 2))
238239
with pytest.raises(ValueError):
239-
b_lfib.setstate([(31, 32, 33, 34, -35), 1])
240+
b_lfib.setstate([(31, 32, 33, 34, -35), 1]) # type: ignore
240241
with pytest.raises(ValueError):
241-
b_lfib.setstate(((31, 32, 33, -34, -35), 1))
242+
b_lfib.setstate(((31, 32, 33, -34, -35), 1)) # type: ignore

0 commit comments

Comments
 (0)