Change heading of table
This commit is contained in:
parent
36c1ff20a4
commit
6c0a3d967f
@ -22,8 +22,10 @@ def write_md(results):
|
|||||||
"""
|
"""
|
||||||
Write to README.md
|
Write to README.md
|
||||||
"""
|
"""
|
||||||
with open("../dummy.md", "w") as f:
|
with open("../README.md", "a") as f:
|
||||||
f.write(results)
|
# f.write(str(results))
|
||||||
|
results.stream = f
|
||||||
|
results.write_table()
|
||||||
|
|
||||||
|
|
||||||
def _file_stem(f):
|
def _file_stem(f):
|
||||||
@ -47,7 +49,7 @@ def timing_Python(path=None, exec_only=1):
|
|||||||
os.chdir(Path(path))
|
os.chdir(Path(path))
|
||||||
python_timings, python_results = [], []
|
python_timings, python_results = [], []
|
||||||
for script in scripts[:exec_only]:
|
for script in scripts[:exec_only]:
|
||||||
print(f"Executing {script}")
|
# print(f"Executing {script}")
|
||||||
_res = run(
|
_res = run(
|
||||||
["python3", f"{script}"], capture_output=True, text=True
|
["python3", f"{script}"], capture_output=True, text=True
|
||||||
).stdout.split("\n")
|
).stdout.split("\n")
|
||||||
@ -64,7 +66,7 @@ def timing_Julia(path=None, exec_only=1):
|
|||||||
os.chdir(Path(path))
|
os.chdir(Path(path))
|
||||||
julia_problem_numbers, julia_timings, julia_results = [], [], []
|
julia_problem_numbers, julia_timings, julia_results = [], [], []
|
||||||
for script in scripts[:exec_only]:
|
for script in scripts[:exec_only]:
|
||||||
print(f"Executing {script}")
|
# print(f"Executing {script}")
|
||||||
_res = run(["julia", f"{script}"], capture_output=True, text=True).stdout.split(
|
_res = run(["julia", f"{script}"], capture_output=True, text=True).stdout.split(
|
||||||
"\n"
|
"\n"
|
||||||
)
|
)
|
||||||
@ -87,12 +89,16 @@ def execute(combine_columns=True, nproblems=-1):
|
|||||||
|
|
||||||
assert len(python_timings) == len(julia_timings)
|
assert len(python_timings) == len(julia_timings)
|
||||||
|
|
||||||
|
not_equal = []
|
||||||
for i, (pr, jr) in enumerate(zip(python_results, julia_results), start=1):
|
for i, (pr, jr) in enumerate(zip(python_results, julia_results), start=1):
|
||||||
try:
|
# print(f"Results for problem {i} are equal? {int(pr[22:]) == int(jr[23:])}")
|
||||||
assert int(pr[22:]) == int(jr[23:])
|
if not int(pr[22:]) == int(jr[23:]):
|
||||||
except ValueError:
|
not_equal.append(i)
|
||||||
print(f"Results for problem {i} are not identical!\n")
|
# try:
|
||||||
continue
|
# int(pr[22:]) == int(jr[23:])
|
||||||
|
# except ValueError:
|
||||||
|
# print(f"Results for problem {i} are not identical!\n")
|
||||||
|
# continue
|
||||||
|
|
||||||
if combine_columns:
|
if combine_columns:
|
||||||
headers = [
|
headers = [
|
||||||
@ -108,7 +114,7 @@ def execute(combine_columns=True, nproblems=-1):
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
writer_comb = MarkdownTableWriter(
|
writer_comb = MarkdownTableWriter(
|
||||||
table_name="Project Euler Solutions",
|
table_name=f"Results for problems {not_equal} are not correct",
|
||||||
headers=headers,
|
headers=headers,
|
||||||
value_matrix=value_matrix,
|
value_matrix=value_matrix,
|
||||||
column_styles=[
|
column_styles=[
|
||||||
@ -119,9 +125,12 @@ def execute(combine_columns=True, nproblems=-1):
|
|||||||
], # specify styles for each column
|
], # specify styles for each column
|
||||||
margin=1, # add a whitespace for both sides of each cell
|
margin=1, # add a whitespace for both sides of each cell
|
||||||
)
|
)
|
||||||
|
writer_comb.set_indent_level(3)
|
||||||
writer_comb.write_table()
|
writer_comb.write_table()
|
||||||
writer_comb.write_null_line()
|
writer_comb.write_null_line()
|
||||||
|
|
||||||
|
return writer_comb
|
||||||
|
|
||||||
else:
|
else:
|
||||||
languages = ["Python", "Julia"]
|
languages = ["Python", "Julia"]
|
||||||
|
|
||||||
@ -142,7 +151,7 @@ def execute(combine_columns=True, nproblems=-1):
|
|||||||
]
|
]
|
||||||
|
|
||||||
writer = MarkdownTableWriter(
|
writer = MarkdownTableWriter(
|
||||||
table_name=f"Project Euler Solutions for {lang}",
|
table_name=f"Results for {lang}",
|
||||||
headers=headers,
|
headers=headers,
|
||||||
value_matrix=value_matrix,
|
value_matrix=value_matrix,
|
||||||
column_styles=[
|
column_styles=[
|
||||||
@ -154,13 +163,13 @@ def execute(combine_columns=True, nproblems=-1):
|
|||||||
)
|
)
|
||||||
writer.write_table()
|
writer.write_table()
|
||||||
writer.write_null_line()
|
writer.write_null_line()
|
||||||
# print(writer.dumps())
|
|
||||||
# return writer.dumps()
|
return writer
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
md = read_md()
|
md = read_md()
|
||||||
# print(md)
|
# print(md)
|
||||||
res = execute(combine_columns=True)
|
res = execute(combine_columns=True, nproblems=-1)
|
||||||
# print(res)
|
# print(res)
|
||||||
# write_md(res)
|
# write_md(res)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user