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.
Python calibrationclassificationdecision-modelhuggingfacejevmodernbertmultilingualnlppythonpytorchroutingtyped-decisionszero-shot
fix(calibrate): refuse wide integers in binning_map values with ValueError (#1435)
Furkan Coban5cc6d8c8c032
diff --git a/laya-dotnet/src/Laya/CalibrationFile.cs b/laya-dotnet/src/Laya/CalibrationFile.csindex c25b49a9..00cdfa97 100644--- a/laya-dotnet/src/Laya/CalibrationFile.cs+++ b/laya-dotnet/src/Laya/CalibrationFile.cs@@ -155,13 +155,13 @@ internal static partial class CalibrationFilethrow Refused($"{at} must have \"values\" of length \"bins\" ({bins.ToString(CultureInfo.InvariantCulture)})");var numbers = $"{at} values must be numbers, got {PythonFloat.Repr(values)}";- // `[float(v) for v in values]` runs over every value before any type check: a value float() refuses is the- // ValueError, and an integer too large for a float is an OverflowError that nothing catches.+ // `[float(v) for v in values]` runs over every value before any type check: a value float() refuses+ // (including an integer wider than a double) raises the ValueError naming `values must be numbers`.var parsed = new double[values.Count];for (var i = 0; i < values.Count; i++){if (values[i] is BigInteger big && double.IsInfinity((double)big))- throw new InvalidDataException("OverflowError: int too large to convert to float");+ throw Refused(numbers);if (!PythonFloat.TryConvert(values[i], out parsed[i])) throw Refused(numbers);}foreach (var v in values)diff --git a/laya/calibrate.py b/laya/calibrate.pyindex bed20578..072a542a 100644--- a/laya/calibrate.py+++ b/laya/calibrate.py@@ -812,7 +812,7 @@ def apply_calibration_payload(obj, payload: Dict[str, Any]) -> None:% (name, n_bins))try:parsed_values = [float(v) for v in values]- except (TypeError, ValueError) as exc:+ except (TypeError, ValueError, OverflowError) as exc:raise ValueError("calibration JSON binning_map[%r] values must be numbers, got %r" % (name, values)) from excfor v in values:diff --git a/tests/test_calibrate.py b/tests/test_calibrate.pyindex 5174333f..bb6b5179 100644--- a/tests/test_calibrate.py+++ b/tests/test_calibrate.py@@ -858,6 +858,9 @@ _refuses("shape/binning Infinity", {"temperature": [1.0, 1.0, 1.0], "binning_map_refuses("shape/binning bool value", {"temperature": [1.0, 1.0, 1.0], "binning_map": {"a": {"bins": 1, "values": [True]}}}, "number")_refuses("shape/binning string value", {"temperature": [1.0, 1.0, 1.0], "binning_map": {"a": {"bins": 1, "values": ["0.5"]}}}, "number")_refuses("shape/binning null value", {"temperature": [1.0, 1.0, 1.0], "binning_map": {"a": {"bins": 1, "values": [None]}}}, "number")+_refuses("shape/binning wide integer value", {"temperature": [1.0, 1.0, 1.0], "binning_map": {"a": {"bins": 1, "values": [10 ** 400]}}}, "number")+_refuses("shape/binning negative wide integer value", {"temperature": [1.0, 1.0, 1.0], "binning_map": {"a": {"bins": 1, "values": [-(10 ** 400)]}}}, "number")+_refuses("shape/binning smallest unconvertible int value", {"temperature": [1.0, 1.0, 1.0], "binning_map": {"a": {"bins": 1, "values": [2 ** 1024]}}}, "number")_refuses("shape/scalar temperature", {"temperature": 5}, "[3 floats]")_refuses("shape/string temperature", {"temperature": "abc"}, "[3 floats]")_refuses("shape/dict temperature", {"temperature": {"a": 1, "b": 2, "c": 3}}, "[3 floats]")