Spaces:
Paused
Paused
Download src/playground/visualize/session_dashboard.py from ThomasHeisig/MHRN-Space: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/ThomasHeisig/MHRN-Space/resolve/main/src/playground/visualize/session_dashboard.py
- Command line
-
hf download hf://spaces/ThomasHeisig/MHRN-Space/src/playground/visualize/session_dashboard.py
-
curl -L -o session_dashboard.py https://huggingface.co/spaces/ThomasHeisig/MHRN-Space/resolve/main/src/playground/visualize/session_dashboard.py
1.01 kB
| """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, | |
| } | |