feat(perception): record E39 R1 refinement
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
from k1link.compute.e39_perception_refinement import (
|
||||
_feature_names,
|
||||
_fit_robust_scaler,
|
||||
_predict_presence,
|
||||
_project_dimensions,
|
||||
_transform,
|
||||
)
|
||||
|
||||
|
||||
def test_e39_feature_contract_and_knn_are_deterministic() -> None:
|
||||
assert len(_feature_names()) == 262
|
||||
matrix = np.asarray(
|
||||
[
|
||||
[0.0, 1.0],
|
||||
[0.1, 1.1],
|
||||
[4.9, 5.0],
|
||||
[5.0, 5.1],
|
||||
],
|
||||
dtype=np.float64,
|
||||
)
|
||||
median, scale = _fit_robust_scaler(matrix)
|
||||
transformed = _transform(matrix, median=median, scale=scale, clip=20.0)
|
||||
first = _predict_presence(
|
||||
transformed[0],
|
||||
transformed[1:],
|
||||
["background", "object", "object"],
|
||||
neighbors=3,
|
||||
)
|
||||
second = _predict_presence(
|
||||
transformed[0],
|
||||
transformed[1:],
|
||||
["background", "object", "object"],
|
||||
neighbors=3,
|
||||
)
|
||||
assert first == second == ("object", 2 / 3)
|
||||
|
||||
|
||||
def test_e39_projects_presence_through_frozen_stratum_ontology() -> None:
|
||||
assert _project_dimensions("camera-only", "object-present") == {
|
||||
"presence": "object-present",
|
||||
"geometry_association": "insufficient-support",
|
||||
"freshness": "unavailable",
|
||||
}
|
||||
assert _project_dimensions("geometry-only", "occupied-environment") == {
|
||||
"presence": "occupied-environment",
|
||||
"geometry_association": "independent-occupied",
|
||||
"freshness": "current",
|
||||
}
|
||||
assert _project_dimensions("unknown", "background-or-noise") == {
|
||||
"presence": "background-or-noise",
|
||||
"geometry_association": "rejected-nonobject",
|
||||
"freshness": "current",
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _module() -> object:
|
||||
path = (
|
||||
Path(__file__).resolve().parents[1]
|
||||
/ "experiments"
|
||||
/ "perception"
|
||||
/ "prepare_e39_worker_package.py"
|
||||
)
|
||||
spec = importlib.util.spec_from_file_location("e39_worker_package_test", path)
|
||||
assert spec is not None and spec.loader is not None
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
sys.modules[spec.name] = module
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
def test_e39_package_contains_bound_camera_lidar_evidence(tmp_path: Path) -> None:
|
||||
module = _module()
|
||||
repository = Path(__file__).resolve().parents[1]
|
||||
acceptance = (
|
||||
repository
|
||||
/ ".runtime"
|
||||
/ "compute-experiments"
|
||||
/ "e37"
|
||||
/ "results"
|
||||
/ (
|
||||
"e37-ravnoves-acceptance-"
|
||||
"01b1efd586f747341c712d82f0907b39436a6f91ae92b1dfae987eca05fd8344"
|
||||
)
|
||||
)
|
||||
materialization = (
|
||||
repository
|
||||
/ ".runtime"
|
||||
/ "compute-experiments"
|
||||
/ "e30"
|
||||
/ "materializations"
|
||||
/ (
|
||||
"e30-materialization-"
|
||||
"841af926d8d28ab93538c46d8f31278a2234c4d1c12c7dc4dc296b249d59735a"
|
||||
)
|
||||
)
|
||||
package = module.build_e39_worker_package(
|
||||
repository_root=repository,
|
||||
acceptance_root=acceptance,
|
||||
materialization_root=materialization,
|
||||
profile_path=(
|
||||
repository
|
||||
/ "experiments"
|
||||
/ "perception"
|
||||
/ "e39_ravnoves00_r1_refinement_profile.json"
|
||||
),
|
||||
output_root=tmp_path,
|
||||
)
|
||||
manifest = module.validate_e39_worker_package(package)
|
||||
assert package.name == f"e39-worker-package-{manifest['identity_sha256']}"
|
||||
assert manifest["identity"]["classification"] == (
|
||||
"immutable-ravnoves00-r1-camera-lidar-worker-input"
|
||||
)
|
||||
assert len(manifest["artifacts"]) > 800
|
||||
assert (
|
||||
package
|
||||
/ "input"
|
||||
/ "materialization"
|
||||
/ materialization.name
|
||||
/ "frames"
|
||||
/ "frame-001005.jpg"
|
||||
).is_file()
|
||||
Reference in New Issue
Block a user