Spaces:
Paused
Paused
File size: 1,013 Bytes
250836c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | """Compact data contract for custom playground dashboards."""
from __future__ import annotations
from collections.abc import Mapping
from .raster import raster_series
from .rate import population_rate_series
from .topology_2d import project_2d
from .topology_5d_projection import project_5d
def dashboard_payload(result: Mapping[str, object]) -> dict[str, object]:
topology = result.get("topology", {})
coordinates = (
topology.get("coordinates", []) if isinstance(topology, Mapping) else []
)
dimensions = (
int(topology.get("dimensions", 0)) if isinstance(topology, Mapping) else 0
)
projection = (
project_5d(coordinates, components=2)
if dimensions >= 4
else project_2d(coordinates)
)
return {
"manifest": result.get("manifest"),
"metrics": result.get("metrics"),
"raster": raster_series(result),
"population_rate_hz": population_rate_series(result),
"topology_projection": projection,
}
|