MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / tabulate

Function tabulate

test/perf/compiled_extensions/command.py:17–44  ·  view source on GitHub ↗
(
    impl_names: list[str],
    result_by_method: dict[str, dict[str, float]],
)

Source from the content-addressed store, hash-verified

15
16
17def tabulate(
18 impl_names: list[str],
19 result_by_method: dict[str, dict[str, float]],
20):
21 if not result_by_method:
22 return
23 dim = max(len(n) for n in impl_names)
24 dim = min(dim, 20)
25
26 width = max(20, *(len(m) + 1 for m in result_by_method))
27
28 string_cell = "{:<%s}" % dim
29 header = "{:<%s}|" % width + f" {string_cell} |" * len(impl_names)
30 num_format = "{:<%s.9f}" % dim
31 csv_row = "{:<%s}|" % width + " {} |" * len(impl_names)
32 print(header.format("", *impl_names))
33
34 for meth in result_by_method:
35 data = result_by_method[meth]
36 strings = [
37 (
38 num_format.format(data[name])[:dim]
39 if name in data
40 else string_cell.format("—")
41 )
42 for name in impl_names
43 ]
44 print(csv_row.format(meth, *strings))
45
46
47def find_git_sha():

Callers 1

mainFunction · 0.85

Calls 2

maxClass · 0.85
minClass · 0.85

Tested by

no test coverage detected