Esempio n. 1
0
 def test_bf_add(self):
     """ test estimate elements is correct """
     blm = BloomFilter(est_elements=10, false_positive_rate=0.05)
     res1 = blm.estimate_elements()
     blm.add("this is a test")
     res2 = blm.estimate_elements()
     self.assertNotEqual(res1, res2)
     self.assertEqual(res1, 0)
     self.assertEqual(res2, 1)
     self.assertEqual(blm.elements_added, 1)
Esempio n. 2
0
 def test_bf_add(self):
     ''' test estimate elements is correct '''
     blm = BloomFilter(est_elements=10, false_positive_rate=0.05)
     res1 = blm.estimate_elements()
     blm.add('this is a test')
     res2 = blm.estimate_elements()
     self.assertNotEqual(res1, res2)
     self.assertEqual(res1, 0)
     self.assertEqual(res2, 1)
     self.assertEqual(blm.elements_added, 1)
Esempio n. 3
0
 def test_bf_all_bits_set(self):
     """test inserting too many elements so that the all bits are set"""
     blm = BloomFilter(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())
Esempio n. 4
0
                    stock_symbol_file.write(check_stock_symbol + "," + ' Defenitely Not Traded\n')
            stock_symbol_file.write('Probably Traded Count,' + str(prob_present_count) + "\n")
            stock_symbol_file.write('Traded Count,' + str(present_count) + "\n")
            stock_symbol_file.write('False +ve Traded Count,' + str(false_postive_count) + "\n")
            stock_symbol_file.write('Definitely Not Traded Count,' + str(not_present_count) + "\n")

            stock_trade_file.close()
            stock_exists_bf.export(stock_exists_bf_filename)

            timenow = datetime.datetime.now()
            bf_endtime = str(timenow.strftime("%x")) + ' ' + str((timenow.strftime("%X")))

            est_elemnts_added_bf = stock_exists_bf.elements_added
            est_elements_planned = stock_exists_bf.estimated_elements
            stocks_added = len(stock_symbol_dist)
            est_unique_elements = stock_exists_bf.estimate_elements()

            process_file.write(str(est_elemnts_added_bf))
            process_file.write("," + str(est_elements_planned))
            process_file.write("," + str(stocks_added))
            process_file.write("," + str(est_unique_elements))
            process_file.write("," + str(false_postive_count))
            process_file.write("," + str(false_postive_count/est_unique_elements))
            process_file.write("," + str(stock_exists_bf.bloom_length))
            process_file.write("," + str(stock_exists_bf.number_hashes))

            process_file.write("," + str(no_of_record))
            process_file.write("," + str(stock_exists_bf.false_positive_rate))
            process_file.write("," + str(stock_exists_bf.current_false_positive_rate()))

            process_file.write("," + str(stock_exists_bf.number_bits))