(task_id: int, entry_point)
| 47 | |
| 48 | |
| 49 | def get_contract_and_ref(task_id: int, entry_point) -> Tuple[str, str]: |
| 50 | mod = import_module(f"groundtruth.humaneval.{str(task_id).zfill(3)}_{entry_point}") |
| 51 | fn = getattr(mod, entry_point) |
| 52 | |
| 53 | doc = fn.__doc__ |
| 54 | if task_id == 51: |
| 55 | doc = doc.replace("bcdf\nghjklm", r"bcdf\nghjklm").replace( |
| 56 | "abcdef\nghijklm", r"abcdef\nghijklm" |
| 57 | ) |
| 58 | |
| 59 | code = ( |
| 60 | getsource(fn).replace(doc, "").replace("''''''", '""""""').split('""""""\n')[-1] |
| 61 | ) |
| 62 | |
| 63 | assert code, f"Something wrong with {task_id}!" |
| 64 | assert code[:3] != "def", f"Something wrong with the {task_id}!" |
| 65 | |
| 66 | # split code to contract and impl |
| 67 | contract = "" |
| 68 | impl = "" |
| 69 | |
| 70 | reading_contract = True |
| 71 | for line in code.strip("\n").split("\n"): |
| 72 | if reading_contract and "$_CONTRACT_$" in line: |
| 73 | contract += line + "\n" |
| 74 | else: |
| 75 | reading_contract = False |
| 76 | impl += line + "\n" |
| 77 | |
| 78 | if contract: |
| 79 | contract = "\n" + contract |
| 80 | |
| 81 | return contract, "\n" + impl + "\n" |
| 82 | |
| 83 | |
| 84 | def get_atol(task_id: int) -> float: |
no outgoing calls
no test coverage detected
searching dependent graphs…