Пример #1
0
 def test_cbf_all_bits_set(self):
     """test inserting too many elements so that the all bits are set"""
     blm = CountingBloomFilter(est_elements=10, false_positive_rate=0.05)
     for i in range(100):
         blm.add(str(i))
     # NOTE: this causes an exception when all bits are set
     self.assertEqual(-1, blm.estimate_elements())
Пример #2
0
 def test_cbf_estimate_2(self):
     """ check estimate elements - different """
     blm = CountingBloomFilter(est_elements=10, false_positive_rate=0.05)
     blm.add("this is a test", 10)
     blm.add("this is a different test", 5)
     self.assertEqual(blm.estimate_elements(), 1)
Пример #3
0
 def test_cbf_estimate_2(self):
     ''' check estimate elements - different '''
     blm = CountingBloomFilter(est_elements=10, false_positive_rate=0.05)
     blm.add('this is a test', 10)
     blm.add('this is a different test', 5)
     self.assertEqual(blm.estimate_elements(), 1)
Пример #4
0
 def test_cbf_estimate_easy(self):
     ''' check estimate elements '''
     blm = CountingBloomFilter(est_elements=10, false_positive_rate=0.05)
     blm.add('this is a test', 10)
     blm.add('this is also a test', 5)
     self.assertEqual(blm.estimate_elements(), 2)
Пример #5
0
 def test_cbf_estimate_easy(self):
     """check estimate elements"""
     blm = CountingBloomFilter(est_elements=20, false_positive_rate=0.05)
     blm.add("this is a test", 10)
     blm.add("this is also a test", 5)
     self.assertEqual(blm.estimate_elements(), 2)