larvaworld.lib.plot.table ========================= .. py:module:: larvaworld.lib.plot.table .. autoapi-nested-parse:: Tables Functions --------- .. autoapisummary:: larvaworld.lib.plot.table.conf_table larvaworld.lib.plot.table.modelConfTable larvaworld.lib.plot.table.mpl_table larvaworld.lib.plot.table.mdiff_table larvaworld.lib.plot.table.error_table larvaworld.lib.plot.table.store_model_graphs larvaworld.lib.plot.table.diff_df Module Contents --------------- .. py:function:: conf_table(df: pandas.DataFrame, row_colors: Sequence[str], mID: str, show: bool = False, save_to: Optional[str] = None, save_as: Optional[str] = None, build_kws: Dict[str, Any] = {'Nrows': 1, 'Ncols': 1, 'w': 15, 'h': 20}, **kwargs: Any) -> Any Create configuration table with color-coded rows. Wrapper around mpl_table that creates a formatted configuration table with module-specific row colors and standard layout. Args: df: Configuration data as DataFrame row_colors: List of colors for each row mID: Model identifier for title show: Whether to display table. Defaults to False save_to: Directory to save table. Defaults to None save_as: Filename for saved table. Defaults to None build_kws: Figure build keywords. Defaults to standard size **kwargs: Additional arguments passed to mpl_table Returns: Plot output (figure object or None based on return_fig setting) Example: >>> fig = conf_table(df, row_colors=['red', 'blue'], mID='model_01') .. py:function:: modelConfTable(mID: str, m: Any = None, columns: Sequence[str] = ['parameter', 'symbol', 'value', 'unit'], colWidths: Sequence[float] = [0.35, 0.1, 0.25, 0.15], **kwargs: Any) -> Any Create configuration table for a model. Generates formatted table showing all model parameters including brain modules, body, physics, sensorimotor, and energetics configurations. Args: mID: Model identifier m: Pre-loaded model object. Loads from mID if None columns: Table columns to display. Defaults to parameter info colWidths: Column width ratios. Defaults to balanced widths **kwargs: Additional arguments passed to conf_table Returns: Plot output (figure object or None based on return_fig setting) Example: >>> fig = modelConfTable(mID='model_01', columns=['parameter', 'value']) .. py:function:: mpl_table(data: pandas.DataFrame, cellLoc: str = 'center', colLoc: str = 'center', rowLoc: str = 'center', font_size: int = 14, title: Optional[str] = None, name: str = 'mpl_table', header0: Optional[str] = None, header0_color: Optional[str] = None, header_color: str = '#40466e', row_colors: Sequence[str] = ('#f1f1f2', 'w'), edge_color: str = 'black', adjust_kws: Optional[Dict[str, Any]] = None, highlighted_celltext_dict: Optional[Dict[str, Sequence[str]]] = None, highlighted_cells: Optional[str] = None, bbox: Sequence[float] = (0, 0, 1, 1), header_columns: int = 0, colWidths: Optional[Sequence[float]] = None, highlight_color: str = 'yellow', return_table: bool = False, **kwargs: Any) -> Any Create matplotlib table with customizable formatting. Generates publication-quality table with customizable colors, highlighting, and formatting options. Supports row/column colors and cell highlighting. Args: data: DataFrame to display as table cellLoc: Cell text alignment. Defaults to 'center' colLoc: Column header alignment. Defaults to 'center' rowLoc: Row index alignment. Defaults to 'center' font_size: Table font size. Defaults to 14 title: Table title. Defaults to None name: Plot name for saving. Defaults to 'mpl_table' header0: Additional header row text. Defaults to None header0_color: Color for additional header. Defaults to None header_color: Main header color. Defaults to '#40466e' row_colors: Alternating row colors. Defaults to light gray/white edge_color: Cell border color. Defaults to 'black' adjust_kws: Figure adjustment keywords. Defaults to None highlighted_celltext_dict: Dict of highlighted cell texts. Defaults to None highlighted_cells: Highlighting mode ('row_min', 'row_max'). Defaults to None bbox: Table bounding box. Defaults to (0, 0, 1, 1) header_columns: Number of header columns. Defaults to 0 colWidths: Column width ratios. Defaults to None highlight_color: Highlight cell color. Defaults to 'yellow' return_table: Return table object instead of figure. Defaults to False **kwargs: Additional arguments passed to AutoBasePlot Returns: Table object if return_table=True, else plot output Example: >>> fig = mpl_table(df, highlighted_cells='row_min', font_size=12) .. py:function:: mdiff_table(mIDs: Sequence[str], dIDs: Sequence[str], show: bool = False, save_to: Optional[str] = None, save_as: Optional[str] = None, **kwargs: Any) -> Any Create table comparing differences between models. Generates table showing only parameters that differ between models, with color-coded rows by module type. Args: mIDs: List of model identifiers to compare dIDs: List of display identifiers for models show: Whether to display table. Defaults to False save_to: Directory to save table. Defaults to None save_as: Filename for saved table. Defaults to None **kwargs: Additional arguments passed to mpl_table Returns: Plot output (figure object or None based on return_fig setting) Example: >>> fig = mdiff_table(mIDs=['model_A', 'model_B'], dIDs=['A', 'B']) .. py:function:: error_table(data: numpy.ndarray, k: str = '', **kwargs: Any) -> Any Create table displaying error metrics. Generates formatted table showing error values (transposed and rounded) for model evaluation. Args: data: Error metric array k: Metric key/label. Defaults to empty string **kwargs: Additional arguments passed to mpl_table Returns: Plot output (figure object or None based on return_fig setting) Example: >>> fig = error_table(error_array, k='RSS') .. py:function:: store_model_graphs(mIDs: Optional[Sequence[str]] = None) -> None Generate and store configuration tables and summary plots for models. Creates model configuration tables and summary plots for all specified models, combining them into master PDFs. Args: mIDs: List of model identifiers. Uses all models if None Example: >>> store_model_graphs(mIDs=['model_01', 'model_02']) .. py:function:: diff_df(mIDs: Sequence[str], ms: Optional[Sequence[Any]] = None, dIDs: Optional[Sequence[str]] = None) -> Tuple[pandas.DataFrame, Sequence[str]] Create difference DataFrame comparing model parameters. Generates DataFrame showing only parameters that differ between models, with row colors for visualization. Args: mIDs: List of model identifiers to compare ms: Pre-loaded model objects. Loads from mIDs if None dIDs: Display identifiers. Uses mIDs if None Returns: Tuple of (difference DataFrame, list of row colors) Example: >>> df, colors = diff_df(mIDs=['model_A', 'model_B'])