fix: graphe calculation

This commit is contained in:
OpenSquared
2026-06-30 12:00:42 +02:00
parent ce7f89cf2a
commit 12c298cf83
2 changed files with 19 additions and 11 deletions

View File

@@ -903,6 +903,8 @@ def analyze_event(body: AnalyzeRequest):
inputs[input_id] = round(raw, 4)
elif src == "surprise" and event.get("surprise_pct") is not None:
raw = float(event["surprise_pct"])
if cfg.get("normalize"):
raw = raw / 100
node_range = cfg.get("range")
if node_range and len(node_range) == 2:
lo, hi = float(node_range[0]), float(node_range[1])
@@ -1224,19 +1226,15 @@ def _run_auto_analysis(event: dict, template_id: int) -> dict:
pass
if sp is not None:
raw = float(sp)
# normalize:true in node cfg → divide by 100 (coefficients calibrated for fraction)
if cfg.get("normalize"):
raw = raw / 100
node_range = cfg.get("range")
if src == "surprise_bps":
if node_range and len(node_range) == 2:
lo, hi = float(node_range[0]), float(node_range[1])
inputs[input_id] = round(max(lo, min(hi, raw)), 4)
else:
inputs[input_id] = round(raw, 4)
if node_range and len(node_range) == 2:
lo, hi = float(node_range[0]), float(node_range[1])
inputs[input_id] = round(max(lo, min(hi, raw)), 4)
else:
if node_range and len(node_range) == 2:
lo, hi = float(node_range[0]), float(node_range[1])
inputs[input_id] = round(max(lo, min(hi, raw)), 4)
else:
inputs[input_id] = round(raw, 4)
inputs[input_id] = round(raw, 4)
elif src == "impact_score_scaled" and event.get("impact_score") is not None:
inputs[input_id] = float(event["impact_score"]) / 10.0