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.

fix(confidence): export the gate vocabulary as one name, not five

Bruce-Yii2d29adb1a34d
diff --git a/laya/__init__.py b/laya/__init__.py
index a5f78587..f8e5279b 100644
--- a/laya/__init__.py
+++ b/laya/__init__.py
@@ -31,10 +31,6 @@ _LAZY_ATTRS = {
"check_min_confidence": (".confidence", "check_min_confidence"),
"flag_low_confidence": (".confidence", "flag_low_confidence"),
"apply_confidence_gate": (".confidence", "apply_confidence_gate"),
- "GATE_NOT_CONFIGURED": (".confidence", "GATE_NOT_CONFIGURED"),
- "GATE_PASSED": (".confidence", "GATE_PASSED"),
- "GATE_ABSTAINED": (".confidence", "GATE_ABSTAINED"),
- "GATE_UNEVALUATED": (".confidence", "GATE_UNEVALUATED"),
"GATE_STATES": (".confidence", "GATE_STATES"),
"render_options": (".common", "render_options"),
"QTYPES": (".common", "QTYPES"),
@@ -97,10 +93,6 @@ __all__ = [
"check_min_confidence",
"flag_low_confidence",
"apply_confidence_gate",
- "GATE_NOT_CONFIGURED",
- "GATE_PASSED",
- "GATE_ABSTAINED",
- "GATE_UNEVALUATED",
"GATE_STATES",
"render_options",
"QTYPES",
diff --git a/tests/test_confidence.py b/tests/test_confidence.py
index f0d99911..ae86d594 100644
--- a/tests/test_confidence.py
+++ b/tests/test_confidence.py
@@ -324,8 +324,18 @@ check_true("export/flag_low_confidence is in dir()", "flag_low_confidence" in di
check_true("export/apply_confidence_gate is importable from laya", hasattr(laya, "apply_confidence_gate"))
check_true("export/apply_confidence_gate is in __all__", "apply_confidence_gate" in laya.__all__)
check_true("export/apply_confidence_gate is in dir()", "apply_confidence_gate" in dir(laya))
-for _name in ("GATE_NOT_CONFIGURED", "GATE_PASSED", "GATE_ABSTAINED", "GATE_UNEVALUATED", "GATE_STATES"):
- check_true("export/%s is importable from laya" % _name, hasattr(laya, _name))
+check_true("export/GATE_STATES is importable from laya", hasattr(laya, "GATE_STATES"))
+check_true("export/GATE_STATES is in __all__", "GATE_STATES" in laya.__all__)
+check_true("export/GATE_STATES is in dir()", "GATE_STATES" in dir(laya))
+# The four values are reached through GATE_STATES rather than exported one by one: iterating the
+# vocabulary is the whole use, and every `laya.__all__` name has to earn a documented entry
+# (`tests/test_packaging.py` enforces that).
+import laya.confidence as _confidence # noqa: E402
+
+check("export/GATE_STATES is the vocabulary a caller iterates", list(GATE_STATES),
+ [_confidence.GATE_NOT_CONFIGURED, _confidence.GATE_PASSED,
+ _confidence.GATE_ABSTAINED, _confidence.GATE_UNEVALUATED])
+check("export/laya re-exports the same tuple", laya.GATE_STATES, _confidence.GATE_STATES)
print("\n%d passed, %d failed" % (len(PASS), len(FAIL)))
for f in FAIL: