From 41be2f1803f8c671eb8f7f68689c3d289b07cdfe Mon Sep 17 00:00:00 2001 From: zq Date: Sat, 30 May 2026 07:47:41 +0800 Subject: [PATCH] fix(scoring): use float() instead of int() for continuous reward scores int() truncates smoothed composite scores (0.0-1.0) to 0, making all continuous reward values appear as failures. This broke SkillOpt training pipelines using SmoothedCompositeReward. --- skillopt/utils/scoring.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/skillopt/utils/scoring.py b/skillopt/utils/scoring.py index 7a1c375..df5d1fe 100644 --- a/skillopt/utils/scoring.py +++ b/skillopt/utils/scoring.py @@ -7,17 +7,16 @@ import hashlib def compute_score(results: list) -> tuple[float, float]: """Compute hard and soft accuracy from a list of episode results. - Accepts both plain dicts and :class:`~skillopt.types.RolloutResult` - instances. + Accepts both plain dicts and :class: instances. hard may be continuous (0.0-1.0) when using smoothed reward. """ if not results: return 0.0, 0.0 - def _hard(r: object) -> int: - return int(r.hard if hasattr(r, "hard") else r.get("hard", 0)) # type: ignore[union-attr] + def _hard(r: object) -> float: + return float(r.hard if hasattr(r, "hard") else r.get("hard", 0)) def _soft(r: object) -> float: - return float(r.soft if hasattr(r, "soft") else r.get("soft", 0.0)) # type: ignore[union-attr] + return float(r.soft if hasattr(r, "soft") else r.get("soft", 0.0)) hard = sum(_hard(r) for r in results) / len(results) soft = sum(_soft(r) for r in results) / len(results)