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())
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)
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)
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)
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)