Skip to content

Commit 70e0afa

Browse files
committed
fix: reject invalid benchmark uncertainty
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
1 parent 194aac7 commit 70e0afa

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

.mise/tasks/generate_benchmark_summary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def score_interval(result: dict) -> tuple[float, float] | None:
273273
return None
274274
try:
275275
error = float(metric.get("scoreError"))
276-
if not math.isnan(error):
276+
if math.isfinite(error) and error >= 0:
277277
return score - error, score + error
278278
except (ValueError, TypeError):
279279
pass

.mise/tasks/test_generate-benchmark-summary.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ def test_zero_or_non_finite_scores_are_inconclusive(self):
100100
comparison_status(result(score=float("inf")), result()), "inconclusive"
101101
)
102102

103+
def test_invalid_fallback_uncertainty_is_inconclusive(self):
104+
for error in (float("inf"), float("-inf"), -1.0):
105+
head = result(error=error)
106+
head["primaryMetric"].pop("scoreConfidence")
107+
self.assertEqual(comparison_status(head, result()), "inconclusive", error)
108+
103109
def test_missing_confidence_interval_is_inconclusive(self):
104110
head = result(score=106, error=None)
105111
self.assertEqual(comparison_status(head, result()), "inconclusive")

0 commit comments

Comments
 (0)