MCPcopy Create free account
hub / github.com/FlyingFeather/DEA-SQL / get_most_voted_values

Function get_most_voted_values

common/wrapper.py:41–62  ·  view source on GitHub ↗
(values_list, mode)

Source from the content-addressed store, hash-verified

39
40
41def get_most_voted_values(values_list, mode):
42 def count_most_common(values):
43 count = Counter(values)
44 most_common = count.most_common()
45 max_votes = most_common[0][1]
46 most_common_candidates = [i[0] for i in most_common if i[1] == max_votes]
47 selected_candidate = random.choice(most_common_candidates)
48 return selected_candidate, dict(count)
49
50 count_results = []
51 vote_stats = []
52
53 if mode == "all":
54 count_result, vote_stat = count_most_common(values_list)
55 count_results, vote_stats = count_result, vote_stat
56 else:
57 for values in values_list:
58 count_result, vote_stat = count_most_common(values)
59 count_results.append(count_result)
60 vote_stats.append(vote_stat)
61
62 return count_results, vote_stats
63
64
65def combine_json(json_list, keys, mode):

Callers 1

combine_jsonFunction · 0.85

Calls 1

count_most_commonFunction · 0.85

Tested by

no test coverage detected