示例#1
0
 def test_replacement(self):
     """ensure that elements are sampled with replacement"""
     items = range(5)
     combo = mi.random_combination_with_replacement(items, len(items) * 2)
     self.assertEqual(2 * len(items), len(combo))
     if len(set(combo)) == len(combo):
         raise AssertionError("Combination contained no duplicates")
示例#2
0
 def test_replacement(self):
     """ensure that elements are sampled with replacement"""
     items = range(5)
     combo = mi.random_combination_with_replacement(items, len(items) * 2)
     self.assertEqual(2 * len(items), len(combo))
     if len(set(combo)) == len(combo):
         raise AssertionError("Combination contained no duplicates")
示例#3
0
 def test_pseudorandomness(self):
     """ensure different subsets of the iterable get returned over many
     samplings of random combinations"""
     items = range(15)
     all_items = set()
     for _ in range(50):
         combination = mi.random_combination_with_replacement(items, 5)
         all_items |= set(combination)
     self.assertEqual(all_items, set(items))
示例#4
0
 def test_pseudorandomness(self):
     """ensure different subsets of the iterable get returned over many
     samplings of random combinations"""
     items = range(15)
     all_items = set()
     for _ in range(50):
         combination = mi.random_combination_with_replacement(items, 5)
         all_items |= set(combination)
     self.assertEqual(all_items, set(items))