TableDisplay

class bapsflib.utils.TableDisplay(rows: List[List[str]], headers: List[str] | None = None)

Bases: object

Class designed to generated the brief summary tables used in the __str__ and __repr__ methods of HDFMapDigitizers and HDFMapControls.

Parameters:
  • rows (List[List[str]]) – List of table rows where each row is a list of strings being the contents of the associated row-column cell. For example, rows[4][3] would be the cell contents of row 5 and column 4.

  • headers (List[str]) – List of strings specifying the table column headers. None if table has no headers. (DEFAULT: None)

Attributes Summary

cell_widths

List of cell widths of the table.

headers

List of table headers.

ncols

Number of columns in the table.

nrows

Number of rows in the table, excluding headers.

rows

List of table rows where each row is a list of strings being the contents of the associated row-column cell.

Methods Summary

auto_insert_horizontal_dividers(on_columns)

Automatically insert horizontal dividers into the table based on cell value switching in columns specified by on_columns.

table_string()

Generate and return the string contain the table associated with rows and headers.

Attributes Documentation

cell_widths

List of cell widths of the table. Length equal to the number of columns, ncols.

headers

List of table headers. Length equal to the number of columns, ncols.

None if table has no headers.

ncols

Number of columns in the table.

nrows

Number of rows in the table, excluding headers.

rows

List of table rows where each row is a list of strings being the contents of the associated row-column cell.

For example, rows[4][3] would be the cell contents of row 5 and column 4.

Methods Documentation

auto_insert_horizontal_dividers(on_columns: List[int])

Automatically insert horizontal dividers into the table based on cell value switching in columns specified by on_columns. Cell β€œswitching” corresponds to when a cell value switches from being empty to non-empty as moving down a column. The horizontal divider will be inserted above the non-empty cell from the associated column to the end of the table.

Parameters:

on_columns (List[int]) – List of column indices to be used for determining where to insert the horizontal divider.

table_string() str

Generate and return the string contain the table associated with rows and headers.