mlrl.testbed.experiments.table module¶
Author Michael Rapp (michael.rapp.ml@gmail.com)
Provides classes for representing tables.
- class mlrl.testbed.experiments.table.Alignment(*values)¶
Bases:
EnumAll possible alignments of a table column.
- AUTO = None¶
- CENTER = 'center'¶
- LEFT = 'left'¶
- RIGHT = 'right'¶
- class mlrl.testbed.experiments.table.Column¶
Bases:
Iterable[Any|None],ABCProvides access to a single column of a table.
- class mlrl.testbed.experiments.table.ColumnWiseTable¶
Bases:
TableA table to which new columns can be added one by one.
- class Column(table: ColumnWiseTable, column_index: int)¶
Bases:
ColumnProvides access to a single column of a ColumnWiseTable.
- class HeaderRow(table: ColumnWiseTable)¶
Bases:
HeaderRowProvides access to the headers of a ColumnWiseTable.
- class Row(table: ColumnWiseTable, row_index: int)¶
Bases:
RowProvides access to a single row of a ColumnWiseTable.
- add_column(*values: Any | None, header: Any | None = None, alignment: Alignment | None = None) ColumnWiseTable¶
Adds a new column to the end of the table.
- Parameters:
values – The values in the column
header – The header of the column or None
alignment – The alignment of the column or None
- Returns:
The modified table
- property alignments: List[Alignment] | None¶
The individual alignments of the columns in the table or None, if no alignments have been specified.
- property columns: Generator[Column, None, None]¶
A generator that provides access to the individual columns in the table.
- property header_row: HeaderRow | None¶
The header row of the table or None, if the table does not have any headers.
- property rows: Generator[Row, None, None]¶
A generator that provides access to the individual rows in the table.
- sort_by_headers() ColumnWiseTable¶
Sorts the columns in the table by their headers.
- Returns:
The sorted table
- to_column_wise_table() ColumnWiseTable¶
Creates and returns a ColumnWiseTable from this table.
- Returns:
The ColumnWiseTable that has been created
- to_row_wise_table() RowWiseTable¶
Creates and returns a RowWiseTable from this table.
- Returns:
The RowWiseTable that has been created
- class mlrl.testbed.experiments.table.HeaderRow¶
Bases:
Iterable[Any|None],ABCProvides access to the headers of a table.
- class mlrl.testbed.experiments.table.Row¶
Bases:
Iterable[Any|None],ABCProvides access to a single row of a table.
- class mlrl.testbed.experiments.table.RowWiseTable(*headers: Any | None, alignments: List[Alignment] | None = None)¶
Bases:
TableA table to which new rows can be added one by one.
- class Column(table: RowWiseTable, column_index: int)¶
Bases:
ColumnProvides access to a single column of a RowWiseTable.
- class HeaderRow(table: RowWiseTable)¶
Bases:
HeaderRowProvides access to the headers of a RowWiseTable.
- class Row(table: RowWiseTable, row_index: int)¶
Bases:
RowProvides access to a single row of a RowWiseTable.
- add_row(*values: Any | None)¶
Adds a new row to the end of the table.
- Parameters:
values – The values in the row
- Returns:
The modified table
- property alignments: List[Alignment] | None¶
The individual alignments of the columns in the table or None, if no alignments have been specified.
- property columns: Generator[Column, None, None]¶
A generator that provides access to the individual columns in the table.
- property header_row: HeaderRow | None¶
The header row of the table or None, if the table does not have any headers.
- property rows: Generator[Row, None, None]¶
A generator that provides access to the individual rows in the table.
- sort_by_columns(column_index: int, *additional_column_indices: int, descending: bool = False) RowWiseTable¶
Sorts the rows in the table by the values in one or several columns.
- Parameters:
column_index – The index of the column to sort by
additional_column_indices – Additional indices of columns to sort by
descending – True, if the rows should be sorted in descending order, False, if they should be sorted in ascending order
- Returns:
The sorted table
- to_column_wise_table() ColumnWiseTable¶
Creates and returns a ColumnWiseTable from this table.
- Returns:
The ColumnWiseTable that has been created
- to_row_wise_table() RowWiseTable¶
Creates and returns a RowWiseTable from this table.
- Returns:
The RowWiseTable that has been created
- class mlrl.testbed.experiments.table.Table¶
Bases:
ABCAn abstract base class for all tables.
- abstract property alignments: List[Alignment] | None¶
The individual alignments of the columns in the table or None, if no alignments have been specified.
- abstract property columns: Generator[Column, None, None]¶
A generator that provides access to the individual columns in the table.
- format(auto_rotate: bool = True) str¶
Creates and returns a textual representation of the table.
- Parameters:
auto_rotate – True, if tables with a single row should automatically be rotated for legibility, False otherwise
- Returns:
The textual representation that has been created
- abstract property header_row: HeaderRow | None¶
The header row of the table or None, if the table does not have any headers.
- abstract property rows: Generator[Row, None, None]¶
A generator that provides access to the individual rows in the table.
- abstractmethod to_column_wise_table() ColumnWiseTable¶
Creates and returns a ColumnWiseTable from this table.
- Returns:
The ColumnWiseTable that has been created
- abstractmethod to_row_wise_table() RowWiseTable¶
Creates and returns a RowWiseTable from this table.
- Returns:
The RowWiseTable that has been created