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