Lines Matching refs:gen
17 return [self.gen.random() for i in xrange(n)]
20 self.gen.seed()
21 state1 = self.gen.getstate()
23 self.gen.seed() # diffent seeds at different times
24 state2 = self.gen.getstate()
29 self.gen.seed()
30 state = self.gen.getstate()
32 self.gen.setstate(state) # should regenerate the same sequence
38 self.gen.seed(arg)
40 self.assertRaises(TypeError, self.gen.seed, arg)
41 self.assertRaises(TypeError, self.gen.seed, 1, 2)
42 self.assertRaises(TypeError, type(self.gen), [])
45 self.gen.seed()
46 state1 = self.gen.getstate()
47 self.gen.jumpahead(100)
48 state2 = self.gen.getstate() # s/b distinct from state1
50 self.gen.jumpahead(100)
51 state3 = self.gen.getstate() # s/b distinct from state2
55 self.assertRaises(TypeError, self.gen.jumpahead) # needs an arg
56 self.assertRaises(TypeError, self.gen.jumpahead, 2, 3) # too many
60 self.gen.seed(199210368)
61 self.gen.jumpahead(13550674232554645900)
63 val = self.gen.random()
72 s = self.gen.sample(population, k)
77 self.assertEqual(self.gen.sample([], 0), []) # test edge case N==k==0
91 perms[tuple(self.gen.sample(pop, k))] = None
99 self.gen.sample(set(range(20)), 2)
100 self.gen.sample(range(20), 2)
101 self.gen.sample(xrange(20), 2)
102 self.gen.sample(str('abcdefghijklmnopqrst'), 2)
103 self.gen.sample(tuple('abcdefghijklmnopqrst'), 2)
106 self.gen.sample(dict.fromkeys('abcdefghijklmnopqrst'), 2)
110 self.gen.sample(a, 3)
118 samp = self.gen.sample(d, k)
131 self.gen.seed(seed)
132 x1 = self.gen.random()
133 y1 = self.gen.gauss(0, 1)
135 self.gen.seed(seed)
136 x2 = self.gen.random()
137 y2 = self.gen.gauss(0, 1)
144 state = pickle.dumps(self.gen, proto)
145 origseq = [self.gen.random() for i in xrange(10)]
164 gen = random.WichmannHill() variable in WichmannHill_TestBasicOps
167 self.assertRaises(ValueError, self.gen.setstate, (2, None, None))
172 s = self.gen.getstate()
173 self.gen.jumpahead(N)
174 r1 = self.gen.random()
176 self.gen.setstate(s)
178 self.gen.random()
179 r2 = self.gen.random()
188 self.gen.whseed(seed)
189 x1 = self.gen.random()
190 y1 = self.gen.gauss(0, 1)
192 self.gen.whseed(seed)
193 x2 = self.gen.random()
194 y2 = self.gen.gauss(0, 1)
203 self.assertRaises(UserWarning, self.gen.randrange, 2**60)
206 gen = random.SystemRandom() variable in SystemRandom_TestBasicOps
210 self.gen.seed()
213 self.assertRaises(NotImplementedError, self.gen.getstate)
214 self.assertRaises(NotImplementedError, self.gen.setstate, None)
218 self.gen.seed(100)
222 self.gen.jumpahead(100)
225 self.gen.gauss_next = None
226 self.gen.seed(100)
227 self.assertEqual(self.gen.gauss_next, None)
231 self.assertRaises(NotImplementedError, pickle.dumps, self.gen, proto)
238 cum |= int(self.gen.random() * span)
247 r = self.gen.randrange(span)
254 start = self.gen.randrange(2 ** (i-2))
255 stop = self.gen.randrange(2 ** i)
258 self.assertTrue(start <= self.gen.randrange(start, stop) < stop)
263 set([self.gen.randrange(start,stop) for i in xrange(100)]))
268 self.assertTrue(0 <= self.gen.getrandbits(k) < 2**k)
271 getbits = self.gen.getrandbits
279 self.assertRaises(TypeError, self.gen.getrandbits)
280 self.assertRaises(TypeError, self.gen.getrandbits, 1, 2)
281 self.assertRaises(ValueError, self.gen.getrandbits, 0)
282 self.assertRaises(ValueError, self.gen.getrandbits, -1)
283 self.assertRaises(TypeError, self.gen.getrandbits, 10.1)
308 gen = random.Random() variable in MersenneTwister_TestBasicOps
320 self.gen.seed(42)
321 expected_value = self.gen.random()
323 self.gen.seed(seed_arg)
324 self.assertEqual(self.gen.random(), expected_value)
327 self.assertRaises(ValueError, self.gen.setstate, (1, None, None))
330 start_state = self.gen.getstate()
332 self.assertRaises(TypeError, self.gen.setstate, (2, None, None))
334 self.assertRaises(ValueError, self.gen.setstate, (2, (1,2,3), None))
336 self.assertRaises(TypeError, self.gen.setstate, (2, ('a',)*625, None))
338 self.assertRaises(TypeError, self.gen.setstate, (2, (0,)*624+('a',), None))
341 self.gen.setstate((2, (1,)*624+(625,), None))
343 self.gen.setstate((2, (1,)*624+(-1,), None))
345 bits100 = self.gen.getrandbits(100)
346 self.gen.setstate(start_state)
347 self.assertEqual(self.gen.getrandbits(100), bits100)
375 self.gen.seed(61731L + (24903L<<32) + (614L<<64) + (42143L<<96))
397 self.gen.seed(61731L + (24903L<<32) + (614L<<64) + (42143L<<96))
409 self.gen.seed(seed)
416 cum |= int(self.gen.random() * span)
425 r = self.gen.randrange(span)
432 start = self.gen.randrange(2 ** (i-2))
433 stop = self.gen.randrange(2 ** i)
436 self.assertTrue(start <= self.gen.randrange(start, stop) < stop)
441 set([self.gen.randrange(start,stop) for i in xrange(100)]))
445 self.gen.seed(1234567)
446 self.assertEqual(self.gen.getrandbits(100),
450 self.assertTrue(0 <= self.gen.getrandbits(k) < 2**k)
453 getbits = self.gen.getrandbits
461 self.assertRaises(TypeError, self.gen.getrandbits)
462 self.assertRaises(TypeError, self.gen.getrandbits, 'a')
463 self.assertRaises(TypeError, self.gen.getrandbits, 1, 2)
464 self.assertRaises(ValueError, self.gen.getrandbits, 0)
465 self.assertRaises(ValueError, self.gen.getrandbits, -1)
492 x = self.gen.randrange(start, stop, step)