"""依頼 355 のまとめ: summary_353 と同じ表 (check_355//) に, 手首の足しの量 (simreplay_355 の faces の列) の表を足す. 爪の面ごとの L・a*・b* (実機 / シム), 爪のふち − 中 の L, ブロックの縁のくっきり具合 (勾配 ÷ 内外の差) とコントラスト, 手首の箱の壁・底の L 依頼 354 の最後 (check_353/final) は tag "s354" (check_355/s354 → ../check_353/final のリンク) で並べる. 読むだけ. 使い方: python so101/sim/summary_355.py --tags s354,lv5,lv6,lv7,lv8 --name steps_355 --eps 0,8,18,28,38 """ import sys from pathlib import Path import numpy as np HERE = Path(__file__).resolve().parent sys.path.insert(0, str(HERE)) import summary_353 as U3 # noqa: E402 OUT = HERE.parent / "check_355" JAW = ("up", "front", "left", "back", "right") def extra(tags, sel): rows = [] for t in tags: _, _, _, x = U3.load(t) if x is not None and sel is not None: x = x[x["new_episode_index"].isin(sel)] rows.append(x) def med(x, col): return float(x[col].median()) if x is not None and col in x and x[col].notna().any() else None def cell(x, a, b, n=1): return f"{U3.fmt(med(x, a), n)} / {U3.fmt(med(x, b), n)}" L = ["", "## 爪の面ごと (手首. 実機 / シム. 面の向きはシムの深さから)", "", "| | " + " | ".join(tags) + " |", "|---|" + "---|" * len(tags)] for j in JAW: for q in "Lab": L.append(f"| 爪 {j} {q} | " + " | ".join(cell(x, f"jaw_{j}_{q}_real", f"jaw_{j}_{q}_sim") for x in rows) + " |") for x_nm, a in (("爪のふち L", "jaw_rim_L"), ("爪の中 L", "jaw_in_L")): L.append(f"| {x_nm} | " + " | ".join(cell(x, f"{a}_real", f"{a}_sim") for x in rows) + " |") def spread(x, tag): if x is None or f"jaw_up_L_{tag}" not in x: return None cols = [f"jaw_{j}_L_{tag}" for j in JAW if f"jaw_{j}_L_{tag}" in x] v = x[cols].median() return float(v.max() - v.min()) L.append("| 爪の面の L の幅 (最大 − 最小) | " + " | ".join(f"{U3.fmt(spread(x, 'real'), 1)} / {U3.fmt(spread(x, 'sim'), 1)}" for x in rows) + " |") def rim(x, tag): a, b = med(x, f"jaw_rim_L_{tag}"), med(x, f"jaw_in_L_{tag}") return None if a is None or b is None else a - b L.append("| 爪のふち − 中 L | " + " | ".join(f"{U3.fmt(rim(x, 'real'), 1)} / {U3.fmt(rim(x, 'sim'), 1)}" for x in rows) + " |") L += ["", "## ブロックの縁のくっきり具合・白箱 (手首. 実機 / シム)", "", "| | " + " | ".join(tags) + " |", "|---|" + "---|" * len(tags)] for nm, a, n in (("縁の勾配 ÷ 内外の差 (1/px)", "block_edge_sharp", 3), ("縁の内外の明るさの差 (灰色)", "block_edge_step", 1), ("縁の勾配 (灰色/px)", "block_edge_grad", 1), ("箱の壁 L", "boxwall_L", 1), ("箱の底 L", "boxfloor_L", 1)): L.append(f"| {nm} | " + " | ".join(cell(x, f"{a}_real", f"{a}_sim", n) for x in rows) + " |") return L def main(): U3.OUT = OUT argv = sys.argv[1:] U3.main() a = dict(zip(argv[::2], argv[1::2])) tags = a["--tags"].split(",") sel = [int(v) for v in a["--eps"].split(",")] if a.get("--eps") else None L = extra(tags, sel) p = OUT / f"{a['--name']}.md" p.write_text(p.read_text() + "\n".join(L) + "\n") print("\n".join(L)) if __name__ == "__main__": main()