def write_sin_dic(result, tmp, score_way, yaml_file, file_flag): flag = 0 for key in result.keys(): if type(result[key]) == list: sublist = result[key] geo_mean = scores_method.geometric_mean(sublist) elif type(result[key]) is types.StringType: geo_mean = string.atof(result[key]) elif type(result[key]) is types.FloatType: geo_mean = result[key] elif type(result[key]) is types.IntType: geo_mean = result[key] else: return -4 tmp.append(key) if file_flag == 2: geo_mean = compute_score(score_way, geo_mean) flag1 = write_yaml_perf(yaml_file, tmp, geo_mean, file_flag) tmp.remove(key) if not flag1: return flag1 flag = 1 return flag
def traverser_perf(target, yaml_file): flag = 0 yaml_file_post = yaml_file[0:-5] + "_post" + yaml_file[-5:] if os.path.exists(yaml_file): shutil.copyfile(yaml_file, yaml_file_post) else: print "No such file %s" % yaml_file flag = -1 return flag fp = open(yaml_file) dic_perf = yaml.load(fp) fp.close() perf_results = dic_perf['results']['Performance'] keys_sub_items = perf_results.keys() for subItem in keys_sub_items: test_point_dic = perf_results[subItem] key_test_points = test_point_dic.keys() values_test_points = [] for test_point in key_test_points: test_case_dic = test_point_dic[test_point] #print test_case_dic point_values = test_case_dic['Point_Scores'].values() useful_values = [ string.atof(x) for x in point_values if string.atof(x) != 0 ] try: last_result = geometric_mean(useful_values) except TypeError, e: print e continue #if 'Total_Score' is not in test_case_dic: # test_case_dic['Total_Score'] = {} test_case_dic['Total_Scores'] = last_result values_test_points.append(last_result) try: total_sub_items_result = geometric_mean(values_test_points) except TypeError, e: print "Compute the last score of subItem %s wrong" % subItem print e
def normalize_score(results): point_str = 'Point_Scores' total_str = 'Total_Scores' keys_sub_items = results.keys() for subItem in keys_sub_items: test_point_dic = results[subItem] key_test_points = test_point_dic.keys() values_test_points = [] # get the geometric value for each point for test_point in key_test_points: test_case_dic = test_point_dic[test_point] point_values = test_case_dic[point_str].values() useful_values = [ string.atof(x) for x in point_values if string.atof(x) >= 0 ] if len(useful_values) < 1: last_result = 0 else: try: last_result = geometric_mean(useful_values) last_result = round(last_result, 2) except TypeError, e: logging.info(e) continue test_case_dic[total_str] = last_result values_test_points.append(last_result) # get geometric value for each testItem if len(values_test_points) < 1: total_sub_items_result = 0 else: try: total_sub_items_result = geometric_mean(values_test_points) except TypeError, e: logging.info("Compute the last score of subItem %s wrong" % subItem) logging.info(e) else:
def normalize_score(results): point_str = 'Point_Scores' total_str = 'Total_Scores' keys_sub_items = results.keys() for subItem in keys_sub_items: test_point_dic = results[subItem] key_test_points = test_point_dic.keys() values_test_points = [] # get the geometric value for each point for test_point in key_test_points: test_case_dic = test_point_dic[test_point] point_values = test_case_dic[point_str].values() useful_values = [string.atof(x) for x in point_values if string.atof(x) >= 0] if len(useful_values) < 1: last_result = 0 else: try: last_result = geometric_mean(useful_values) last_result = round(last_result, 2) except TypeError, e: logging.info(e) continue test_case_dic[total_str] = last_result values_test_points.append(last_result) # get geometric value for each testItem if len(values_test_points) < 1: total_sub_items_result = 0 else: try: total_sub_items_result = geometric_mean(values_test_points) except TypeError, e: logging.info("Compute the last score of subItem %s wrong" % subItem) logging.info(e) else: