def test_c_cuckoo_filter_rmv_miss(self): """ test removing from the counting cuckoo filter when not present """ cko = CountingCuckooFilter() cko.add("this is a test") self.assertEqual(cko.elements_added, 1) cko.add("this is another test") self.assertEqual(cko.elements_added, 2) cko.add("this is yet another test") self.assertEqual(cko.elements_added, 3) res = cko.remove("this is still a test") self.assertFalse(res) self.assertEqual(cko.elements_added, 3) self.assertTrue(cko.check("this is a test")) self.assertTrue(cko.check("this is another test")) self.assertTrue(cko.check("this is yet another test"))
def test_c_cuckoo_filter_rmv_miss(self): ''' test removing from the counting cuckoo filter when not present ''' cko = CountingCuckooFilter() cko.add('this is a test') self.assertEqual(cko.elements_added, 1) cko.add('this is another test') self.assertEqual(cko.elements_added, 2) cko.add('this is yet another test') self.assertEqual(cko.elements_added, 3) res = cko.remove('this is still a test') self.assertFalse(res) self.assertEqual(cko.elements_added, 3) self.assertTrue(cko.check('this is a test')) self.assertTrue(cko.check('this is another test')) self.assertTrue(cko.check('this is yet another test'))
def test_c_cuckoo_filter_remove(self): """ test removing from the counting cuckoo filter """ cko = CountingCuckooFilter() cko.add("this is a test") self.assertEqual(cko.elements_added, 1) cko.add("this is another test") self.assertEqual(cko.elements_added, 2) cko.add("this is yet another test") self.assertEqual(cko.elements_added, 3) self.assertEqual(cko.unique_elements, 3) cko.add("this is a test") cko.add("this is a test") cko.add("this is a test") self.assertEqual(cko.elements_added, 6) self.assertEqual(cko.unique_elements, 3) res = cko.remove("this is another test") self.assertTrue(res) self.assertEqual(cko.elements_added, 5) self.assertEqual(cko.unique_elements, 2) self.assertTrue(cko.check("this is a test")) self.assertFalse(cko.check("this is another test")) self.assertTrue(cko.check("this is yet another test"))
def test_c_cuckoo_filter_remove(self): ''' test removing from the counting cuckoo filter ''' cko = CountingCuckooFilter() cko.add('this is a test') self.assertEqual(cko.elements_added, 1) cko.add('this is another test') self.assertEqual(cko.elements_added, 2) cko.add('this is yet another test') self.assertEqual(cko.elements_added, 3) self.assertEqual(cko.unique_elements, 3) cko.add('this is a test') cko.add('this is a test') cko.add('this is a test') self.assertEqual(cko.elements_added, 6) self.assertEqual(cko.unique_elements, 3) res = cko.remove('this is another test') self.assertTrue(res) self.assertEqual(cko.elements_added, 5) self.assertEqual(cko.unique_elements, 2) self.assertTrue(cko.check('this is a test')) self.assertFalse(cko.check('this is another test')) self.assertTrue(cko.check('this is yet another test'))
from probables import (CuckooFilter) from probables import (CountingCuckooFilter) cko = CuckooFilter(capacity=100, max_swaps=10) cko.add('google.com') cko.check('facebook.com') # should return False cko.check('google.com') # should return True cck = CountingCuckooFilter(capacity=100, max_swaps=10) cck.add("google") cck.add("google") cck.add("google") print(cck.check("google")) cck.remove("google") print(cck.check("google"))