Provision balanced Belgian training portfolio
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user