File size: 1,901 Bytes
64ddf8d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #!/usr/bin/env python
def to_latex(bits, nbit, cols=10):
v = len(bits) // cols
rows = v if len(bits) % cols == 0 else v + 1
for i, bit in enumerate(bits):
if i == 0:
print("\\midrule")
print(
"\\multirowcell{" + str(rows) + "}{\\textbf{" + str(nbit) + "-bit}} ",
end="",
)
print(f"& {bit:.2f} ", end="")
if (i + 1) % cols == 0:
print(r" \\")
elif i == len(bits) - 1:
padding = " &" * (cols - (i + 1) % cols)
print(f"{padding} \\\\")
def main(ncols=10):
head = f"""
\\begin{{table*}}
\\centering
\\caption[SensiMiLP/KurtMiLP Experiment Settings]{{
The SensiMiLP/KurtMiLP dense experiment bit budget settings.
}}
\\label{{tab:sensi-kurt-milp-settings}}
\\begin{{tabular}}{{r{'l' * ncols}}}
\\toprule
"""
heading = r"\textbf{Group} & "
fields = [f" \\textbf{{V{i}}}" for i in range(1, ncols + 1)]
heading += "&".join(fields)
heading += r" \\"
tail = r"""
\bottomrule
\end{tabular}
\end{table*}
"""
with open("dense.txt", "r") as fh:
bits = [float(f) for f in fh.readlines()]
bits8 = [f for f in bits if f >= 8.0]
bits7 = [f for f in bits if f >= 7.0 and f < 8.0]
bits6 = [f for f in bits if f >= 6.0 and f < 7.0]
bits5 = [f for f in bits if f >= 5.0 and f < 6.0]
bits4 = [f for f in bits if f >= 4.0 and f < 5.0]
bits3 = [f for f in bits if f >= 3.0 and f < 4.0]
bits2 = [f for f in bits if f >= 2.0 and f < 3.0]
print(head)
print(heading)
to_latex(bits8, 8, ncols)
to_latex(bits7, 7, ncols)
to_latex(bits6, 6, ncols)
to_latex(bits5, 5, ncols)
to_latex(bits4, 4, ncols)
to_latex(bits3, 3, ncols)
to_latex(bits2, 2, ncols)
print(tail)
if __name__ == "__main__":
main(12)
|