mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-05-01 04:01:14 +00:00
Support older versions of tabulate module.
Ubuntu 18.04 only provides tabulate v0.7, but colalign and github formatting options were added in 0.8.3.
This commit is contained in:
@@ -7,6 +7,12 @@ import sys
|
|||||||
|
|
||||||
import tabulate
|
import tabulate
|
||||||
|
|
||||||
|
# Parse version string into tuple, "x.y.z" -> (x, y, z)
|
||||||
|
def version_tuple(v):
|
||||||
|
return tuple(map(int, (v.split("."))))
|
||||||
|
|
||||||
|
tabulate_version = version_tuple(tabulate.__version__)
|
||||||
|
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 3:
|
||||||
print("Usage: %s reference.json compare.json\n" % sys.argv[0])
|
print("Usage: %s reference.json compare.json\n" % sys.argv[0])
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@@ -230,10 +236,17 @@ def compare_benches(ref_benches, cmp_benches):
|
|||||||
|
|
||||||
rows.append(row)
|
rows.append(row)
|
||||||
|
|
||||||
print(tabulate.tabulate(rows,
|
# colalign and github format require tabulate 0.8.3
|
||||||
headers=headers,
|
if tabulate_version >= (0, 8, 3):
|
||||||
colalign=colalign,
|
print(tabulate.tabulate(rows,
|
||||||
tablefmt="github"))
|
headers=headers,
|
||||||
|
colalign=colalign,
|
||||||
|
tablefmt="github"))
|
||||||
|
else:
|
||||||
|
print(tabulate.tabulate(rows,
|
||||||
|
headers=headers,
|
||||||
|
tablefmt="markdown"))
|
||||||
|
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user