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_framedoes 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"includedlog_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.
- 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 Noneguard 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.
- 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.
- 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_unitscallback: it receives the unit string for a single column (Noneif the loader has none) followed by that column’s name.