Example #1
0
 def test_synthetic_EQF_5(self):
     d = EqualFrequency(5, 0)
     p2t = {1:[]}
     p2t[1] = [TimeStamp(-75,1,1,0),TimeStamp(25,1,1,0)] # min = -75, max = 25
     expected_cutpoints = {1:[-55,-35,-15,5]}
     d.discretize_property_without_abstracting({},{},p2t,1)
     real_cutpoints = d.bins_cutpoints
     res, msg = assert_almost_equality(expected_cutpoints,real_cutpoints)
     self.assertTrue(res,msg)
Example #2
0
 def test_synthetic_EQF_Stress_Big_Request_4(self):
     p2t = {1: [TimeStamp(i,1,1,0) for i in range(STRESS_VALUE_COUNT)]}
     max_index = STRESS_VALUE_COUNT - 1
     BIN_COUNT = 4
     d = EqualFrequency(BIN_COUNT, 0)
     d.discretize_property_without_abstracting({}, {}, p2t, 1)
     expected_res = {1:[i*max_index/BIN_COUNT for i in range(1,BIN_COUNT)]}
     res = d.bins_cutpoints
     res, msg = assert_almost_equality(expected_res,res)
     self.assertTrue(res,msg)
Example #3
0
    def test_real_EQF_FAAgeGroup_F3_Property_44(self):
        PROPERTY_ID = 44
        EXPECTED_RES = [0.71,0.84,0.95,1.1]

        d = EqualFrequency(5, 0)
        d.property_folder = PARTITIONS_PATH
        d.discretize_property_without_abstracting({}, {}, {}, PROPERTY_ID)
        real_cutpoints = d.bins_cutpoints
        expected_cutpoints = {PROPERTY_ID: EXPECTED_RES}
        res, msg = assert_almost_equality(expected_cutpoints, real_cutpoints)

        self.assertTrue(res,msg)
Example #4
0
 def test_synthetic_EQF_Stress_Many_Requests(self):
     res = True
     msg = ""
     p2t = {1: [TimeStamp(0,1,1,0),TimeStamp(1,1,1,0)]}
     for bin_count in range(2,10000):
         d = EqualFrequency(bin_count, 0)
         d.discretize_property_without_abstracting({},{},p2t,1)
         sum_real_cutpoints = sum(d.bins_cutpoints[1])
         expected_sum = (bin_count-1)/2
         t_res, t_msg = assert_almost_equality({1:[expected_sum]}, {1:[sum_real_cutpoints]})
         res &= t_res
         msg += t_msg
     self.assertTrue(res,msg)