Provision balanced Belgian training portfolio
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

This commit is contained in:
Jens
2026-07-27 01:22:46 +02:00
parent 9f05451f04
commit b01da996a9
3 changed files with 199 additions and 0 deletions
@@ -0,0 +1,34 @@
from __future__ import annotations
import importlib.util
import sys
from collections import Counter
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
SPEC = importlib.util.spec_from_file_location(
"building_portfolio", ROOT / "scripts" / "provision_belgium_building_training_portfolio.py"
)
assert SPEC and SPEC.loader
module = importlib.util.module_from_spec(SPEC)
sys.modules[SPEC.name] = module
SPEC.loader.exec_module(module)
def test_portfolio_covers_every_region_split_and_context_family() -> None:
assert len({aoi.slug for aoi in module.AOIS}) == len(module.AOIS)
counts = Counter((aoi.region, aoi.split) for aoi in module.AOIS)
for region in module.REGION_CONTRACT:
assert counts[(region, "train")] >= 4
assert counts[(region, "val")] >= 2
assert counts[(region, "calibration")] >= 2
assert counts[(region, "test")] >= 2
assert counts[(region, "background-test")] >= 2
def test_portfolio_bbox_is_metric_sized() -> None:
bbox = module.bbox_for_center(4.35, 50.85, 256.0)
to_metric = module.Transformer.from_crs("EPSG:4326", "EPSG:31370", always_xy=True)
bounds = to_metric.transform_bounds(bbox["min_x"], bbox["min_y"], bbox["max_x"], bbox["max_y"])
assert 255 <= bounds[2] - bounds[0] <= 258
assert 255 <= bounds[3] - bounds[1] <= 258