def test_weighted_average_one_file(self): # metrics [A, B, C] histories = [ [0, 1, 2], # file 1 ] file_sizes = [ 1, ] target = [0, 1, 2] averaged_histories = weighted_average(histories, file_sizes) self.assertSequenceEqual(averaged_histories, target)
def test_weighted_average_one_metric(self): # metrics [A, ] histories = [ [0, ], # file 1 [3, ], # file 2 ] file_sizes = [ 1, 3, ] target = [ (0*1 + 3*3)/4, ] averaged_histories = weighted_average(histories, file_sizes) self.assertSequenceEqual(averaged_histories, target)
def test_weighted_average(self): # metrics [A, B, C] histories = [ [0, 1, 2], # file 1 [3, 4, 5], # file 2 ] file_sizes = [ 1, 3, ] target = [ (0*1 + 3*3)/4, (1*1 + 4*3)/4, (2*1 + 5*3)/4, ] averaged_histories = weighted_average(histories, file_sizes) self.assertSequenceEqual(averaged_histories, target)