Beispiel #1
0
 def test_sublist_of(self):
     s = Gen.sublist_of([1, 2, 3, 4, 5])
     for i in range(10):
         ss = Gen.eval(1, new_seed(), s)
         self.assertTrue(0 <= len(ss) <= 5)
         for v in ss:
             self.assertTrue(v in {1, 2, 3, 4, 5})
Beispiel #2
0
 def sample(cls, size, n, gn):
     def _sample(i, seed, samples):
         if 0 == i:
             return samples
         else:
             samples = [Gen.eval(size, seed, gn)] + samples
             return _sample(
                 i - 1,
                 StdGen.std_split(seed)[1],
                 samples
             )
     return _sample(n, random.new_seed(), [])
Beispiel #3
0
 def Next(self):
     s = new_seed()
     return self.gen(s.a, new_seed())