JalGuard / backend /utils /scoring.py
KaustavMP
Fix grader scores: clamp to strictly open interval (0.01, 0.99)
d87b4bd
Raw History Blame Contribute Delete
352 Bytes
from __future__ import annotations
import math
def clamp_score(raw: float) -> float:
# Validator requires strictly between 0 and 1, not 0.0 or 1.0.
try:
value = float(raw)
except (TypeError, ValueError):
value = 0.0
if not math.isfinite(value):
value = 0.0
return max(0.01, min(0.99, round(value, 4)))