fix: graphe calculation

This commit is contained in:
OpenSquared
2026-06-30 11:45:55 +02:00
parent 05d2a2c841
commit ce7f89cf2a

View File

@@ -906,14 +906,9 @@ def analyze_event(body: AnalyzeRequest):
node_range = cfg.get("range")
if node_range and len(node_range) == 2:
lo, hi = float(node_range[0]), float(node_range[1])
bound = max(abs(lo), abs(hi))
if bound <= 10:
# Plage type z-score : normalise surprise_pct → [-bound, +bound]
inputs[input_id] = round(max(lo, min(hi, raw / 100 * bound)), 4)
else:
inputs[input_id] = round(max(lo, min(hi, raw)), 4)
inputs[input_id] = round(max(lo, min(hi, raw)), 4)
else:
inputs[input_id] = round(raw / 100, 4) # fractional par défaut
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
elif src == "impact_score_pct" and event.get("impact_score") is not None:
@@ -1239,13 +1234,9 @@ def _run_auto_analysis(event: dict, template_id: int) -> dict:
else:
if node_range and len(node_range) == 2:
lo, hi = float(node_range[0]), float(node_range[1])
bound = max(abs(lo), abs(hi))
if bound <= 10:
inputs[input_id] = round(max(lo, min(hi, raw / 100 * bound)), 4)
else:
inputs[input_id] = round(max(lo, min(hi, raw)), 4)
inputs[input_id] = round(max(lo, min(hi, raw)), 4)
else:
inputs[input_id] = round(raw / 100, 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