mirror of
https://github.com/wassname/evil_MoE.git
synced 2026-08-15 10:45:01 +08:00
plots: dejargon, drop redundant titles, emit png+svg+pdf, CSV re-render
Audit of all 4 plot scripts (plot_dynamics/substrate/emergence/deploy_overlay): - One save_fig(fig, path) helper in figs.py writes png+svg+pdf (vector for the paper, png for the blog). All scripts call it. - arm_label() map: reader-facing names only -- route2->route, drop 'knob'/'the cheat' from titles and the train-vs-deploy story (adapter on/off, reward hack). - Titles off by default (the paper/blog caption carries it); --title re-enables for standalone research use. - dump_data CSV now carries every plotted series; plot_dynamics --from-csv re-renders the three figures from the committed CSV with no logs (logs/ and out/runs/ are gitignored; out/figs/*.csv is tracked). Round-trip verified. - Commit the regenerated dyn_sub4 figures in all 3 formats + the CSV. Co-Authored-By: Claudypoo <288921227+claudypoo@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,33 @@ from pathlib import Path
|
||||
|
||||
FIGS_DIR = Path("docs/figs")
|
||||
|
||||
# Reader-facing arm names. Code/log tags carry our internal vocabulary
|
||||
# (route2 = the current routing arm; "knob" = the delta_S adapter); plots must
|
||||
# not. Map every internal tag to the word a paper reader sees. Anything missing
|
||||
# falls through to its raw tag, so a new arm shows up loud rather than silently
|
||||
# mislabelled.
|
||||
ARM_DISPLAY = {
|
||||
"routing2": "route", "route2": "route",
|
||||
"routing2_grad": "route", "routing2_act": "route (act)",
|
||||
"projected": "erase", "route": "route", "erase": "erase", "vanilla": "vanilla",
|
||||
}
|
||||
|
||||
|
||||
def arm_label(tag: str) -> str:
|
||||
return ARM_DISPLAY.get(tag, tag)
|
||||
|
||||
|
||||
def save_fig(fig, png_path: Path, formats=("png", "svg", "pdf")) -> Path:
|
||||
"""Save one figure to every format (vector .svg/.pdf for the paper, .png for
|
||||
the blog/preview) and return the .png path. matplotlib picks the writer from
|
||||
the suffix, so we just swap it. bbox_inches='tight' so titleless figures
|
||||
don't leave a margin where the suptitle used to be."""
|
||||
png_path = Path(png_path)
|
||||
png_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
for ext in formats:
|
||||
fig.savefig(png_path.with_suffix(f".{ext}"), dpi=150, bbox_inches="tight")
|
||||
return png_path
|
||||
|
||||
|
||||
def link_latest(out_path: Path) -> Path:
|
||||
"""Point docs/figs/<out_path.name> at out_path (relative symlink). Returns the link."""
|
||||
|
||||
Reference in New Issue
Block a user