From 9beb8a781350f7db9604e201c3411e3547a6bcc7 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Fri, 9 Oct 2026 14:37:50 +0200 Subject: [PATCH] battery: align the run table's pairs on their slashes, the ticks in a column of their own Each rugnux / reference pair is now rugnux right-aligned to a fixed width, "/", the reference left-aligned to the same width ("-" for a missing value), so every slash of a column sits on one line; the tick or cross follows the space-group pair in its own column. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01SVmAWnzCmRKAXVUCdc4iNi --- tools/battery/report.py | 64 +++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/tools/battery/report.py b/tools/battery/report.py index 87d834715..cc8196bed 100644 --- a/tools/battery/report.py +++ b/tools/battery/report.py @@ -690,37 +690,45 @@ def refres_note(r): def console_table(res): - """One line per set for a terminal or a CI log, each column rugnux / reference: the space - group with a tick where the set passed by score.judge's rule and a cross where it failed (a - lattice, symmetry, crash or missing input), d_min, ISa, CC1/2 overall and in the highest shell, - R_meas of the lowest shell, the model's R-free (rugnux's placement / the model's published) and + """One line per set for a terminal or a CI log, each pair rugnux / reference: the space group, + then a tick where the set passed by score.judge's rule and a cross where it failed (a lattice, + symmetry, crash or missing input), d_min, ISa, CC1/2 overall and in the highest shell, R_meas + of the lowest shell, the model's R-free (rugnux's placement / the model's published) and rugnux's own wall time. The references are XDS's on the XDS arms; the open arm has the - deposition's space group, d_min and R-free only.""" + deposition's space group, d_min and R-free only. Every pair is rugnux right-aligned, "/", the + reference left-aligned, so the slashes (and the ticks) of a column line up.""" def sg(no): - return gemmi.find_spacegroup_by_number(no).short_name() if no else "-" + return gemmi.find_spacegroup_by_number(no).short_name() if no else None - def two(a, b, fmt="{:.1f}", scale=1): - return "/".join(f(None if x is None else x * scale, fmt) for x in (a, b)) + def num(x, fmt, scale): + return None if x is None else fmt.format(x * scale) - mark = {"pass": "✓", "fail": "✗", "not_run": "✗"}.get - head = ("set", "arm", "space group", "d_min", "ISa", "CC1/2%", "hi CC1/2%", "lo Rmeas%", - "R_free%", "time_s") - width = (18, 7, 18, 11, 11, 11, 11, 11, 11, 6) - lines = [head] + # (header, key, reference key, format, scale, width of each side) + pairs = (("space group", "sgno", "sgno_ref", None, 1, 7), + ("d_min", "d_min", "d_min_ref", "{:.2f}", 1, 5), + ("ISa", "isa", "isa_ref", "{:.1f}", 1, 5), + ("CC1/2%", "cc_half", "cc_half_ref", "{:.1f}", 100, 5), + ("hi CC1/2%", "cc_half_high", "cc_half_high_ref", "{:.1f}", 100, 5), + ("lo Rmeas%", "lowres_r_meas", "lowres_r_meas_ref", "{:.1f}", 100, 5), + ("R_free%", "rfree", "rfree_deposited", "{:.1f}", 100, 5)) + mark = {"pass": "✓", "fail": "✗", "not_run": "✗"} + + def line(name, arm, cells, tick, time): + out = f"{name:18} {arm:7}" + for n, (_, _, _, _, _, w) in enumerate(pairs): + out += " " + cells[n] + if n == 0: + out += " " + tick + return f"{out} {time:>6}" + + head = line("set", "arm", [h.center(2 * w + 1) for h, *_, w in pairs], " ", "time_s") + out = [head.rstrip(), "-" * len(head)] for r in res: - name = r["set"] if len(r["set"]) <= width[0] else r["set"][:width[0] - 1] + "~" - lines.append((name, r["arm"], f"{sg(r.get('sgno'))}/{sg(r.get('sgno_ref'))} {mark(r['verdict'], '?')}", - two(r.get("d_min"), r.get("d_min_ref"), "{:.2f}"), - two(r.get("isa"), r.get("isa_ref")), - two(r.get("cc_half"), r.get("cc_half_ref"), scale=100), - two(r.get("cc_half_high"), r.get("cc_half_high_ref"), scale=100), - two(r.get("lowres_r_meas"), r.get("lowres_r_meas_ref"), scale=100), - two(r.get("rfree"), r.get("rfree_deposited"), scale=100), - f(r.get("wall_s"), "{:.0f}"))) - out = [] - for i, cols in enumerate(lines): - out.append(" ".join(c.ljust(w) if j < 3 else c.rjust(w) - for j, (c, w) in enumerate(zip(cols, width))).rstrip()) - if i == 0: - out.append("-" * len(out[0])) + name = r["set"] if len(r["set"]) <= 18 else r["set"][:17] + "~" + cells = [] + for _, k, kr, fmt, scale, w in pairs: + a, b = ((sg(r.get(k)), sg(r.get(kr))) if fmt is None + else (num(r.get(k), fmt, scale), num(r.get(kr), fmt, scale))) + cells.append(f"{a or '-':>{w}}/{b or '-':<{w}}") + out.append(line(name, r["arm"], cells, mark.get(r["verdict"], "?"), f(r.get("wall_s"), "{:.0f}"))) return "\n".join(out)