Fix row height in excel files

This commit is contained in:
2021-09-27 11:38:23 +02:00
parent d09ab98a46
commit 7a4409bb1f
3 changed files with 60 additions and 40 deletions

2
.gitignore vendored
View File

@@ -128,6 +128,8 @@ dmypy.json
# Pyre type checker # Pyre type checker
.pyre/ .pyre/
.idea/
# Results # Results
results/* results/*
exreport/exreport_output/* exreport/exreport_output/*

View File

@@ -338,6 +338,8 @@ class Excel(BaseReport):
) )
bold = self.book.add_format({"bold": True, "font_size": 14}) bold = self.book.add_format({"bold": True, "font_size": 14})
self.sheet.write(self.row + 1, 0, message, bold) self.sheet.write(self.row + 1, 0, message, bold)
for c in range(self.row + 2):
self.sheet.set_row(c, 20)
self.book.close() self.book.close()
@@ -468,7 +470,7 @@ class Benchmark:
fout = open(os.path.join(Folders.results, Files.exreport_output), "w") fout = open(os.path.join(Folders.results, Files.exreport_output), "w")
ferr = open(os.path.join(Folders.results, Files.exreport_err), "w") ferr = open(os.path.join(Folders.results, Files.exreport_err), "w")
result = subprocess.run( result = subprocess.run(
["Rscript", os.path.join(Folders.src, "benchmark.r")], ["Rscript", os.path.join(Folders.src, Files.benchmark_r)],
stdout=fout, stdout=fout,
stderr=ferr, stderr=ferr,
) )
@@ -523,7 +525,6 @@ class Benchmark:
results = Benchmark.build_results() results = Benchmark.build_results()
book = xlsxwriter.Workbook(Benchmark.get_excel_file_name()) book = xlsxwriter.Workbook(Benchmark.get_excel_file_name())
sheet = book.add_worksheet("Benchmark") sheet = book.add_worksheet("Benchmark")
datasets = results[list(results)[0]]
normal = book.add_format({"font_size": 14}) normal = book.add_format({"font_size": 14})
decimal = book.add_format({"num_format": "0.000000", "font_size": 14}) decimal = book.add_format({"num_format": "0.000000", "font_size": 14})
merge_format = book.add_format( merge_format = book.add_format(
@@ -534,8 +535,11 @@ class Benchmark:
"font_size": 14, "font_size": 14,
} }
) )
row = row_init = 3
def header():
nonlocal row
sheet.merge_range(0, 0, 1, 0, "Benchmark of Models", merge_format) sheet.merge_range(0, 0, 1, 0, "Benchmark of Models", merge_format)
row = 3
# Set column width # Set column width
sheet.set_column(0, 0, 40) sheet.set_column(0, 0, 40)
for column in range(2 * len(results)): for column in range(2 * len(results)):
@@ -556,6 +560,10 @@ class Benchmark:
sheet.write(row, column, "Accuracy", merge_format) sheet.write(row, column, "Accuracy", merge_format)
sheet.write(row, column + 1, "Stdev", merge_format) sheet.write(row, column + 1, "Stdev", merge_format)
column += 2 column += 2
def body():
nonlocal row
datasets = results[list(results)[0]]
for dataset, _ in datasets.items(): for dataset, _ in datasets.items():
row += 1 row += 1
sheet.write(row, 0, f"{dataset:30s}", normal) sheet.write(row, 0, f"{dataset:30s}", normal)
@@ -575,4 +583,13 @@ class Benchmark:
decimal, decimal,
) )
column += 1 column += 1
def footer():
for c in range(row_init, row + 1):
sheet.set_row(c, 20)
header()
body()
footer()
book.close() book.close()

View File

@@ -19,6 +19,7 @@ class Files:
cmd_open_macos = "/usr/bin/open" cmd_open_macos = "/usr/bin/open"
cmd_open_linux = "/usr/bin/xdg-open" cmd_open_linux = "/usr/bin/xdg-open"
exreport_pdf = "Rplots.pdf" exreport_pdf = "Rplots.pdf"
benchmark_r = "benchmark.r"
@staticmethod @staticmethod
def best_results(model): def best_results(model):