From 37300f2c4efd909c17d5d4f34f42036639976b54 Mon Sep 17 00:00:00 2001 From: Sven Geboers Date: Sun, 29 Mar 2026 19:34:45 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20add=20motion=20expander=20to=20compass?= =?UTF-8?q?=20tab=20=E2=80=94=20shows=20top=20motions=20per=20axis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- explorer.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/explorer.py b/explorer.py index eb14731..00f2641 100644 --- a/explorer.py +++ b/explorer.py @@ -1028,6 +1028,51 @@ def build_compass_tab(db_path: str, window_size: str) -> None: ): st.caption(_y_interp) + # Motion expander — show which motions define each axis for this window + x_top = axis_def.get("x_top_motions", {}).get(window_idx, {}) + y_top = axis_def.get("y_top_motions", {}).get(window_idx, {}) + x_conf = axis_def.get("x_label_confidence", {}).get(window_idx) + y_conf = axis_def.get("y_label_confidence", {}).get(window_idx) + evr = axis_def.get("explained_variance_ratio", [None, None]) + evr0 = evr[0] if evr else None + + _has_motion_data = bool( + x_top.get("+") or x_top.get("-") or y_top.get("+") or y_top.get("-") + ) + if _has_motion_data: + with st.expander("\U0001f50d Wat bepaalt deze assen?"): + x_conf_pct = ( + f" (vertrouwen: {x_conf:.0%})" if x_conf is not None else "" + ) + y_conf_pct = ( + f" (vertrouwen: {y_conf:.0%})" if y_conf is not None else "" + ) + + st.markdown(f"**Horizontale as: {_x_label}**{x_conf_pct}") + x_pos_titles = x_top.get("+", []) + x_neg_titles = x_top.get("-", []) + if x_pos_titles: + labels_pos = " · ".join(f"{t} ({d})" for t, d in x_pos_titles[:3]) + st.markdown(f"  ➕ {labels_pos}") + if x_neg_titles: + labels_neg = " · ".join(f"{t} ({d})" for t, d in x_neg_titles[:3]) + st.markdown(f"  ➖ {labels_neg}") + + st.markdown(f"**Verticale as: {_y_label}**{y_conf_pct}") + y_pos_titles = y_top.get("+", []) + y_neg_titles = y_top.get("-", []) + if y_pos_titles: + labels_pos = " · ".join(f"{t} ({d})" for t, d in y_pos_titles[:3]) + st.markdown(f"  ➕ {labels_pos}") + if y_neg_titles: + labels_neg = " · ".join(f"{t} ({d})" for t, d in y_neg_titles[:3]) + st.markdown(f"  ➖ {labels_neg}") + + if evr0 is not None: + st.caption( + f"As 1 verklaart {evr0:.1%} van de variantie in stemgedrag." + ) + # --- Voting discipline section --- _MIN_MOTIONS_FOR_DISCIPLINE = 5 start_date, end_date = _window_to_dates(window_idx)