Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

test(evals): pin every falsy tolerance map the guard refuses

Aashish5c5e5e7276a4
diff --git a/laya/evals.py b/laya/evals.py
index d1c6fe79..29f1c745 100644
--- a/laya/evals.py
+++ b/laya/evals.py
@@ -103,8 +103,9 @@ def _tolerance_map(tolerances: Any) -> Dict[str, Any]:
``float(tolerances.get(metric, 0.0))``. A string, null, list or dict there raised ``TypeError``
from inside the arithmetic and a list or string given as the whole map raised
``AttributeError``, so the gate died with exit 1 -- the code `laya-evals` reserves for a
- quality failure -- on what is a broken gate parameter. A bool was read as 1.0, which for a
- metric that lives in [0, 1] accepts any drift the run can report.
+ quality failure -- on what is a broken gate parameter. The falsy shapes (`0`, `0.0`, `""`, `()`)
+ were quieter still: ``tolerances or {}`` read them as no tolerances at all. A bool was read as
+ 1.0, which for a metric that lives in [0, 1] accepts any drift the run can report.
``Infinity`` is the one number that cannot fail a comparison: every finite drift is inside it,
so naming a metric with it turns that metric's gate into a no-op while the run still exits 0
diff --git a/tests/test_evals.py b/tests/test_evals.py
index 2c06d6cd..1aae5eb3 100644
--- a/tests/test_evals.py
+++ b/tests/test_evals.py
@@ -1756,9 +1756,10 @@ def test_compare_refuses_a_tolerance_that_cannot_fail():
with pytest.raises(EvalError, match="is not a number, got %s" % kind):
report.compare(baseline, {"choice_accuracy": value})
- # The map itself: a list or string of pairs, a number, and the empty tuple all used to reach
- # `.get`, and the falsy ones (`0`, `()`) were read as "no tolerances" by `tolerances or {}`.
- for bad in ([("choice_accuracy", 0.1)], "0.1", 5, 0, ()):
+ # The map itself: a list or string of pairs, a number, and the falsy shapes `0`, `0.0`, `""`
+ # and `()`, which `tolerances or {}` used to read as "no tolerances at all" -- a gate parameter
+ # silently replaced by its absence.
+ for bad in ([("choice_accuracy", 0.1)], "0.1", 5, 0, 0.0, "", ()):
with pytest.raises(EvalError, match="tolerances must be an object"):
report.compare(baseline, bad)