diff --git a/analysis/axis_classifier.py b/analysis/axis_classifier.py index f0fe24e..d14cf92 100644 --- a/analysis/axis_classifier.py +++ b/analysis/axis_classifier.py @@ -162,12 +162,14 @@ def _load_motion_vectors(db_path: str, window_id: str) -> Dict[int, np.ndarray]: import duckdb conn = duckdb.connect(db_path, read_only=True) - rows = conn.execute( - "SELECT entity_id, vector FROM svd_vectors " - "WHERE entity_type = 'motion' AND window_id = ?", - [window_id], - ).fetchall() - conn.close() + try: + rows = conn.execute( + "SELECT entity_id, vector FROM svd_vectors " + "WHERE entity_type = 'motion' AND window_id = ?", + [window_id], + ).fetchall() + finally: + conn.close() result: Dict[int, np.ndarray] = {} for entity_id, vector_raw in rows: try: @@ -248,11 +250,13 @@ def _fetch_motion_titles( placeholders = ", ".join("?" for _ in motion_ids) conn = duckdb.connect(db_path, read_only=True) - rows = conn.execute( - f"SELECT id, title, date FROM motions WHERE id IN ({placeholders})", - motion_ids, - ).fetchall() - conn.close() + try: + rows = conn.execute( + f"SELECT id, title, date FROM motions WHERE id IN ({placeholders})", + motion_ids, + ).fetchall() + finally: + conn.close() return {int(row[0]): (str(row[1]), str(row[2])) for row in rows} except Exception as exc: _logger.debug("Failed to fetch motion titles: %s", exc) diff --git a/explorer.py b/explorer.py index 424f521..d8ca142 100644 --- a/explorer.py +++ b/explorer.py @@ -204,6 +204,7 @@ def _swap_axes( ("x_interpretation", "y_interpretation"), ("x_top_motions", "y_top_motions"), ("x_label_confidence", "y_label_confidence"), + ("x_axis", "y_axis"), ]: new_ax[x_key] = axis_def.get(y_key) new_ax[y_key] = axis_def.get(x_key) @@ -1065,7 +1066,7 @@ def build_compass_tab(db_path: str, window_size: str) -> None: if evr0 is not None: st.caption( - f"As 1 verklaart {evr0:.1%} van de variantie in stemgedrag." + f"De sterkste component verklaart {evr0:.1%} van de variantie in stemgedrag." ) # --- Voting discipline section ---