MCPcopy
hub / github.com/evalplus/evalplus / deduplicate

Function deduplicate

tools/collect_valid_solutions.py:108–125  ·  view source on GitHub ↗

Deduplicate solutions

(solutions: List[str])

Source from the content-addressed store, hash-verified

106
107
108def deduplicate(solutions: List[str]) -> List[str]:
109 """Deduplicate solutions"""
110 asts = set()
111 deduplicated = []
112 for solution in solutions:
113 solution = re.sub(r"#[^\n]*", "", solution)
114 solution = re.sub(r'"""[^"]*"""', "", solution)
115 solution = re.sub(r"'''[^']*'''", "", solution)
116 try:
117 ast_string = ast.dump(ast.parse(solution))
118 except SyntaxError:
119 continue
120 except MemoryError:
121 continue
122 if ast_string not in asts:
123 asts.add(ast_string)
124 deduplicated.append(solution)
125 return list(deduplicated)
126
127
128def test_solutions(

Callers 1

scriptFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected