chore: add TRAJ DEBUG print checkpoints to build_trajectories_tab
This commit is contained in:
+22
@@ -1599,10 +1599,17 @@ def build_compass_tab(db_path: str, window_size: str) -> None:
|
||||
|
||||
|
||||
def build_trajectories_tab(db_path: str, window_size: str) -> None:
|
||||
print(
|
||||
f"[TRAJ DEBUG] build_trajectories_tab called — db_path={db_path}, window_size={window_size}"
|
||||
)
|
||||
st.subheader("Partij Trajectories")
|
||||
st.markdown("Hoe bewegen partijen over de tijdsvensters heen?")
|
||||
|
||||
positions_by_window, axis_def = load_positions(db_path, window_size)
|
||||
print(
|
||||
f"[TRAJ DEBUG] load_positions → {len(positions_by_window)} windows, "
|
||||
f"total MPs={sum(len(v) for v in positions_by_window.values())}"
|
||||
)
|
||||
if axis_def is None:
|
||||
axis_def = {}
|
||||
if not positions_by_window:
|
||||
@@ -1636,6 +1643,10 @@ def build_trajectories_tab(db_path: str, window_size: str) -> None:
|
||||
return
|
||||
|
||||
party_map = load_party_map(db_path)
|
||||
print(
|
||||
f"[TRAJ DEBUG] load_party_map → {len(party_map)} entries, "
|
||||
f"sample={list(party_map.items())[:3]}"
|
||||
)
|
||||
windows = sorted(positions_by_window.keys())
|
||||
|
||||
# Compute party centroids per window
|
||||
@@ -1669,6 +1680,13 @@ def build_trajectories_tab(db_path: str, window_size: str) -> None:
|
||||
float(np.mean(ys)),
|
||||
)
|
||||
|
||||
all_parties = sorted(
|
||||
set(party_map.get(mp) for MPs in positions_by_window.values() for mp in MPs)
|
||||
- {None, "Unknown"}
|
||||
)
|
||||
print(
|
||||
f"[TRAJ DEBUG] all_parties (raw from party_map) → {len(all_parties)} parties: {all_parties[:10]}"
|
||||
)
|
||||
all_parties_sorted = sorted(all_parties)
|
||||
|
||||
# If no parties were found after mapping MPs to parties, show a helpful
|
||||
@@ -2102,6 +2120,10 @@ def choose_trajectory_title(axis_def: dict, axis: str, threshold: float = 0.65)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
print(
|
||||
f"[TRAJ DEBUG] About to render plotly chart — trace_count={trace_count}, "
|
||||
f"banner={banner_text}, fig has {len(fig.data)} traces"
|
||||
)
|
||||
st.plotly_chart(fig, use_container_width=True)
|
||||
except Exception as e:
|
||||
st.error(f"Trajectories rendering failed: {e}")
|
||||
|
||||
Reference in New Issue
Block a user