Skip to content

Commit

Permalink
Replace "\n" with os.linesep
Browse files Browse the repository at this point in the history
  • Loading branch information
Alnusjaponica committed Nov 2, 2023
1 parent 08db792 commit 42cace9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions optuna/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def _dump_value(records: List[Dict[str, Any]], header: List[str]) -> str:
for column_name in header:
row.append(str(record.get(column_name, "")))
values.append(" ".join(row))
return "\n".join(values)
return os.linesep.join(values)


def _dump_table(records: List[Dict[str, Any]], header: List[str]) -> str:
Expand Down Expand Up @@ -223,11 +223,11 @@ def _dump_table(records: List[Dict[str, Any]], header: List[str]) -> str:
rows_string[i] += " " + row[column].get_string(value_type, max_width) + " |"

ret = ""
ret += separator + "\n"
ret += header_string + "\n"
ret += separator + "\n"
ret += "\n".join(rows_string) + "\n"
ret += separator + "\n"
ret += separator + os.linesep
ret += header_string + os.linesep
ret += separator + os.linesep
ret += os.linesep.join(rows_string) + os.linesep
ret += separator + os.linesep

return ret

Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ def _parse_output(output: str, output_format: str) -> Any:
if output_format == "value":
# Currently, _parse_output with output_format="value" is used only for
# `study-names` command.
return [{"name": values} for values in output.split("\n")]
return [{"name": values} for values in output.split(os.linesep)]
elif output_format == "table":
rows = output.split("\n")
rows = output.split(os.linesep)
assert all(len(rows[0]) == len(row) for row in rows)
# Check ruled lines.
assert rows[0] == rows[2] == rows[-1]
Expand Down

0 comments on commit 42cace9

Please sign in to comment.