Exemplo n.º 1
0
 def test_cbf_inter_error_msg(self):
     ''' test intersection of two counting bloom filters type error msg '''
     blm1 = CountingBloomFilter(est_elements=10, false_positive_rate=0.01)
     msg = ('The parameter second must be of type CountingBloomFilter')
     try:
         blm1.intersection(1)
     except TypeError as ex:
         self.assertEqual(str(ex), msg)
     else:
         self.assertEqual(True, False)
Exemplo n.º 2
0
 def test_cbf_inter_error_msg(self):
     """ test intersection of two counting bloom filters type error msg """
     blm1 = CountingBloomFilter(est_elements=10, false_positive_rate=0.01)
     msg = "The parameter second must be of type CountingBloomFilter"
     try:
         blm1.intersection(1)
     except TypeError as ex:
         self.assertEqual(str(ex), msg)
     else:
         self.assertEqual(True, False)
Exemplo n.º 3
0
    def test_cbf_inter(self):
        """test calculating the intersection between two
        counting bloom filters"""
        blm1 = CountingBloomFilter(est_elements=100, false_positive_rate=0.05)
        blm1.add("this is a test", 10)
        blm1.add("this is a different test", 10)
        blm2 = CountingBloomFilter(est_elements=100, false_positive_rate=0.05)
        blm2.add("this is a test", 10)
        res = blm1.intersection(blm2)

        self.assertEqual(res.check("this is a test"), 20)
        self.assertEqual(res.check("this is a different test"), 0)
        self.assertEqual(res.check("this is not a test"), 0)
        self.assertEqual(res.elements_added, 1)
Exemplo n.º 4
0
    def test_cbf_inter(self):
        ''' test calculating the intersection between two
            counting bloom filters '''
        blm1 = CountingBloomFilter(est_elements=100, false_positive_rate=0.05)
        blm1.add('this is a test', 10)
        blm1.add('this is a different test', 10)
        blm2 = CountingBloomFilter(est_elements=100, false_positive_rate=0.05)
        blm2.add('this is a test', 10)
        res = blm1.intersection(blm2)

        self.assertEqual(res.check('this is a test'), 20)
        self.assertEqual(res.check('this is a different test'), 0)
        self.assertEqual(res.check('this is not a test'), 0)
        self.assertEqual(res.elements_added, 1)
Exemplo n.º 5
0
 def test_cbf_inter_diff(self):
     """ test intersection of an mismath of counting bloom filters """
     blm1 = CountingBloomFilter(est_elements=101, false_positive_rate=0.01)
     blm2 = CountingBloomFilter(est_elements=10, false_positive_rate=0.01)
     self.assertEqual(blm1.intersection(blm2), None)
Exemplo n.º 6
0
 def test_cbf_inter_error(self):
     """ test intersection of two counting bloom filters type error """
     blm1 = CountingBloomFilter(est_elements=10, false_positive_rate=0.01)
     self.assertRaises(TypeError, lambda: blm1.intersection(1))
Exemplo n.º 7
0
 def test_cbf_inter_diff(self):
     ''' test intersection of an mismath of counting bloom filters '''
     blm1 = CountingBloomFilter(est_elements=101, false_positive_rate=0.01)
     blm2 = CountingBloomFilter(est_elements=10, false_positive_rate=0.01)
     self.assertEqual(blm1.intersection(blm2), None)
Exemplo n.º 8
0
 def test_cbf_inter_error(self):
     ''' test intersection of two counting bloom filters type error '''
     blm1 = CountingBloomFilter(est_elements=10, false_positive_rate=0.01)
     self.assertRaises(TypeError, lambda: blm1.intersection(1))