ClusteringController

class ClusteringController(available_subclasses: Optional[Mapping[str, List[str]]] = None, **kwargs)

Bases: MetaController

Subclass of MetaController for managing clustering view-model logic.

Handles queries, data relaying, and view updates.

Public Methods

ClusteringController.check_cluster_column(loader: str) → None

Ask the database whether a clustering result is already stored.

First of the commit path’s two round trips; the View shows the overwrite confirmation when this comes back non-None.

Parameters:

loader (str) – the database loader’s plugin key

Returns:

None

Return type:

None

ClusteringController.cluster(plot_data: DataFrame, frame_columns: List[str], log_flags: List[bool], exclude_cols: List[str], method: str, params: Dict[str, Any]) → None

Cluster a frame the View has loaded, and hand the result back to it.

A request slot, the same shape as RawDataController.calculate_psd: the View asks, this calls the Model, and the result goes back through a setter.

A failure is reported on the status panel rather than raised, because nothing above this slot is a call site that could handle it - Qt invoked it from a signal. That covers the filtering as well, since build_clustering_frame does it, so a missing column is reported here rather than raised out of the View.

Parameters:
  • plot_data (pd.DataFrame) – the rows the loader returned, unfiltered

  • frame_columns (List[str]) – the columns to carry through, "id" included

  • log_flags (List[bool]) – per column, whether to log-scale it, index-aligned with frame_columns

  • exclude_cols (List[str]) – columns to leave un-normalized

  • method (str) – the clustering method the user chose

  • params (Dict[str, Any]) – that method’s already-parsed parameters

Returns:

None

Return type:

None

ClusteringController.commit_clusters(loader: str, cluster_data: Any, table_name: str, drop_from_table: str | None) → None

Write the clustering result, dropping any existing one first.

Second of the commit path’s two round trips. A failed drop stops the commit - writing the new columns on top of a half-deleted old result would leave the database in a state the user has to repair by hand.

Parameters:
  • loader (str) – the database loader’s plugin key

  • cluster_data (Any) – the id, label and confidence columns to write

  • table_name (str) – the table to write them into

  • drop_from_table (Optional[str]) – the table to drop an existing result from, or None

Returns:

None

Return type:

None

ClusteringController.display_write_status(status: bool) → None

Notify the display panel whether clustering data was successfully written to the database.

Parameters:

status (bool) – True if the write succeeded, False otherwise.

ClusteringController.load_metadata_for_clustering(config: Dict[str, Any], loader: str) → None

Build the metadata query, load its rows, and hand them to the View.

One request for the query and its rows, rather than two whose answers are read back off the View a statement later. That pattern twice shipped a plot of the previous subset’s rows: a look-up that failed left the attribute holding the last successful value, and the is None guard read it as this subset’s answer.

Both failure cases are reported on the status panel rather than raised, because Qt invoked this from a signal.

Parameters:
  • config (Dict[str, Any]) – the settings dialog’s configuration

  • loader (str) – the database loader’s plugin key

Returns:

None

Return type:

None

ClusteringController.request_column_names(loader: str) → None

Fetch the loader’s column names and hand them to the View.

A failed lookup is reported on the status panel here rather than leaving the View holding the previous loader’s columns.

Parameters:

loader (str) – the database loader’s plugin key

Returns:

None

Return type:

None

ClusteringController.request_column_units(loader: str, column: str) → None

Fetch one column’s unit string and hand it to the View.

Same conversion as request_column_names.

Parameters:
  • loader (str) – the database loader’s plugin key

  • column (str) – the column whose unit is wanted

Returns:

None

Return type:

None

ClusteringController.update_column_names(column_names: List[str]) → None

Update the view with a new list of column names from the database.

Parameters:

column_names (List[str]) – List of column names to populate axis selection.

ClusteringController.update_column_units(column_units: str | None, axis: str) → None

Update unit labels for a given axis in the view.

Despite the parameter names, this is a get_column_units callback: it receives the unit string for a single column (None if the loader has none) followed by that column’s name.

Parameters:
  • column_units (Optional[str]) – Unit string for the column named by axis, or None if the loader could not resolve one.

  • axis (str) – Name of the column whose unit was resolved.

Private Methods

ClusteringController._init() → None

Initialize the clustering view and model components.

ClusteringController._setup_connections() → None

Connect internal view signals to their corresponding controller slots.