fix(SAC_LSTM_Bot): un-invert dashboard axes — orientation selftest added
This commit is contained in:
@@ -250,7 +250,7 @@ def legend(items, x, y):
|
||||
def map_fn(p0, p1, vmin, vmax, log=False):
|
||||
def f(v):
|
||||
t = (math.log10(v) - vmin) / (vmax - vmin) if log else (v - vmin) / (vmax - vmin)
|
||||
return p1 - max(0.0, min(1.0, t)) * (p1 - p0)
|
||||
return p0 + max(0.0, min(1.0, t)) * (p1 - p0)
|
||||
return f
|
||||
|
||||
|
||||
@@ -532,6 +532,22 @@ def selftest():
|
||||
assert text.count("<circle") == 6, text.count("<circle")
|
||||
# 2 trends + 2 real-fight opp lines + 2 losses + 1 alpha + 1 throughput
|
||||
assert text.count("<polyline") == 8, text.count("<polyline")
|
||||
|
||||
# orientation guard: a known rising series (10% -> 90%) rendered through
|
||||
# the FULL build path must plot upward (smaller SVG y) and forward in
|
||||
# time (larger x). Fails loudly if axis mapping is ever inverted again.
|
||||
ori_log = td / "ori.log"
|
||||
ori_log.write_text(
|
||||
">>> [eval] win rate: 1/10 (10%) vs Corners\n"
|
||||
">>> [eval] win rate: 9/10 (90%) vs Corners\n")
|
||||
ori_dash = td / "ori.svg"
|
||||
assert build_dashboard(ori_log, td / "m.jsonl", td / "g.jsonl", ori_dash)
|
||||
m = re.search(r'<polyline points="([^"]+)"', ori_dash.read_text())
|
||||
pts = [tuple(map(float, p.split(","))) for p in m.group(1).split()]
|
||||
assert len(pts) == 2, pts
|
||||
(xa, ya), (xb, yb) = pts
|
||||
assert yb < ya, f"y-axis inverted: win % rose 10->90 but ink moved down ({ya} -> {yb})"
|
||||
assert xb > xa, f"x-axis reversed: newer eval plotted left ({xa} -> {xb})"
|
||||
print("selftest OK")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user