Skip to content

Commit

Permalink
Fix spacing to match published versions
Browse files Browse the repository at this point in the history
When regenerating prompts, I found that these changes are necessary to
avoid some trivial changes to whitespaces in the version published
on the Hugging Face Hub.
  • Loading branch information
arjunguha committed Jul 5, 2024
1 parent 19a2567 commit 012a63a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dataset_builder/humaneval_to_cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ def translate_prompt(self, name: str, args: List[ast.arg], _returns, description
indent = " "
comment_start = self.indent + "//"
csharp_description = (
comment_start +" " + re.sub(DOCSTRING_LINESTART_RE, "\n" + comment_start + " ", description.strip() + "\n"
comment_start +" " + re.sub(DOCSTRING_LINESTART_RE, "\n" + comment_start + " ", description.strip()
))
self.args_type = [self.translate_pytype(arg.annotation) for arg in args]
formal_args = [f"{self.translate_pytype(arg.annotation)} {self.gen_var(arg.arg)[0]}" for arg in args]
formal_arg_list = ", ".join(formal_args)
self.entry_point = to_camel_case(name)
self.ret_ann = _returns
self.translated_return_type = self.translate_pytype(_returns) #make it ret_translated_type
csharp_prompt = f"{self.module_imports()}{class_decl}{csharp_description}{self.indent}public static {self.translated_return_type} {self.entry_point}({formal_arg_list})" + " {\n"
csharp_prompt = f"{self.module_imports()}{class_decl}{csharp_description}\n{self.indent}public static {self.translated_return_type} {self.entry_point}({formal_arg_list})" + " {\n"

return csharp_prompt

Expand Down
2 changes: 1 addition & 1 deletion dataset_builder/humaneval_to_lua.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def file_ext(self) -> str:

def translate_prompt(self, name: str, args: List[ast.arg], _returns: ast.expr, description: str) -> str:
lua_description = (
"-- " + description.replace("\n", "\n-- ") + "\n" if description else ""
"-- " + description.strip().replace("\n", "\n-- ") + "\n" if description else ""
)
arg_names = [arg.arg for arg in args]
arg_list = ", ".join(arg_names)
Expand Down
2 changes: 1 addition & 1 deletion dataset_builder/humaneval_to_r.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self):

def translate_prompt(self, name: str, args: List[ast.arg], returns, description: str) -> str:
r_description = (
"# " + description.replace("\n", "\n# ") +
"# " + description.strip().replace("\n", "\n# ") +
"\n" if description else ""
)
self.type = [[arg.annotation for arg in args], returns]
Expand Down
2 changes: 1 addition & 1 deletion dataset_builder/humaneval_to_rkt.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def file_ext(self):
def translate_prompt(self, name: str, args: List[ast.arg], _returns, description: str) -> str:
# print(description)
racket_description = (
"#lang racket\n;; " + description.replace("\n", "\n;; ") +
"#lang racket\n\n;; " + description.strip().replace("\n", "\n;; ") +
"\n" if description else ""
)
arg_names = [arg.arg for arg in args]
Expand Down

0 comments on commit 012a63a

Please sign in to comment.