MCPcopy Create free account
hub / github.com/SalesforceAIResearch/perfcodegen / get_solution_num_distribution

Method get_solution_num_distribution

src/dataset.py:595–618  ·  view source on GitHub ↗
(self, solution_file = None)

Source from the content-addressed store, hash-verified

593
594
595 def get_solution_num_distribution(self, solution_file = None):
596 self.load_groundtruths(file_path = solution_file)
597 prompts, overlong_prompts = self.get_all_prompts()
598
599 data = {}
600
601 max_num = 0
602 for prompt in (prompts + overlong_prompts):
603 if prompt in self.prompt2groundtruth and len(self.prompt2groundtruth[prompt]) > 0:
604 if len(self.prompt2groundtruth[prompt]) not in data:
605 data[len(self.prompt2groundtruth[prompt])] = 0
606 data[len(self.prompt2groundtruth[prompt])] += 1
607 if len(self.prompt2groundtruth[prompt]) > max_num:
608 max_num = len(self.prompt2groundtruth[prompt])
609
610 lines = ["Solution_Num,#Problems"]
611 for i in range(1, max_num + 1):
612 if i in data:
613 lines.append(f"{i},{data[i]}")
614 else:
615 lines.append(f"{i},0")
616
617 with open(os.path.join(self.data_path, "solution_dist_time_different.csv"), "w", encoding = "utf-8") as f:
618 f.write("\n".join(lines))
619
620
621 def print_info(self):

Callers

nothing calls this directly

Calls 2

load_groundtruthsMethod · 0.95
get_all_promptsMethod · 0.95

Tested by

no test coverage detected