feat: wire ReplayStatsTracker into SessionController + complete GraphView.updateTrend

This commit is contained in:
jack
2026-06-20 18:28:55 -07:00
parent 7206334a27
commit 20a34e22ee
3 changed files with 73 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
import numpy as np
class ReplayStatsTracker:
"""Accumulates per-frames statistic acrossa replay session."""
def __init__(self) -> None:
self.history: list[dict] = []
self.running_avg: float = 0.0
def track(self, frame_index: int, temperatures: list[float]) -> dict:
arr = np.array(temperatures, dtype = np.float32)
clean_arr = arr[np.isfinite(arr)]
if clean_arr.size == 0:
stats = {"frame": frame_index, "min":0.0, "max":0.0, "avg":0.0, "std":0.0}
else:
stats = {
"frame": frame_index,
"min": float(np.min(clean_arr)),
"max": float(np.max(clean_arr)),
"avg": float(np.mean(clean_arr)),
"std": float(np.std(clean_arr)),
}
self.history.append(stats)
if self.history:
self.running_avg = float(np.mean([s["avg"] for s in self.history]))
return stats
def get_trend(self) -> list[float]:
"""Return list of per-frame average for trend chat"""
return [s["avg"] for s in self.history]
def reset(self) -> None:
self.history.clear()
self.running_avg = 0.0