Files
geointel/backend/tests/test_belgium_training_iteration_assessment.py
T
Jens e607cbe724
GeoIntel release gates / Compile, test, contracts and builds (push) Canceled after 0s
GeoIntel release gates / Python and npm vulnerability policy (push) Canceled after 0s
GeoIntel release gates / GIS image, SBOM and container scan (push) Canceled after 0s
Add fail-closed Belgian training loop
2026-07-27 02:29:14 +02:00

27 lines
997 B
Python

from __future__ import annotations
import importlib.util
from pathlib import Path
SCRIPT = Path(__file__).parents[2] / "scripts" / "assess_belgium_building_training_iteration.py"
SPEC = importlib.util.spec_from_file_location("iteration_assessment", SCRIPT)
assert SPEC and SPEC.loader
MODULE = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(MODULE)
def test_calibration_selection_prefers_worst_region_then_aggregate() -> None:
report = {
"sweeps": [
{"threshold": 0.1, "pure_empty_false_positives": 0, "aggregate": {"f1": 0.8}, "regions": {"a": {"f1": 0.2}}},
{"threshold": 0.2, "pure_empty_false_positives": 0, "aggregate": {"f1": 0.6}, "regions": {"a": {"f1": 0.5}}},
]
}
assert MODULE.select_calibration_threshold(report)["threshold"] == 0.2
def test_threshold_lookup_is_exact() -> None:
report = {"sweeps": [{"threshold": 0.25, "aggregate": {}}]}
assert MODULE.find_threshold(report, 0.25)["threshold"] == 0.25