report.Table#

class Table#

Bases: ReportItem

Represents a table within a report, with configurable data and headers.

Attributes

data: list[str | Delta | DataItem]#

A list of table data entries, which can be either strings or Delta objects.

section_title: str, optional#

The title of the table section.

headers: Optional[list[str]]#

List of column headers for the table, default is None.

Default:

None

select_indices: list[int], optional#

Specific indices to select for the chart.

Default:

None

formatter: str | list[str, optional], optional#

Formatter can be a single str (e.g. “.4g”) or a list of str of the same length as data

Default:

None

Additional Constructors

classmethod from_file(filename)#

Loads a Flow360BaseModel from .json, or .yaml file.

Parameters:

filename (str) – Full path to the .yaml or .json file to load the Flow360BaseModel from.

Returns:

An instance of the component class calling load.

Return type:

Flow360BaseModel

Example

>>> params = Flow360BaseModel.from_file(filename='folder/sim.json') 

Methods

get_requirements()#

Returns requirements for this item

calculate_table_data(context)#

Calculate raw table data (headers + rows) without formatting.

Returns:

(headers, rows)

headers: list of column names (strings) rows: list of rows, each row is a list of cell values

Parameters:

context (ReportContext)

Return type:

Tuple[List[str], List[List]]

to_dataframe(context)#

Convert calculated data into a Pandas DataFrame for unit-testing or external usage.

Parameters:

context (ReportContext)

get_doc_item(context, settings=None)#

Returns a LaTeX doc item (Tabulary) for the table, using previously calculated data.

Parameters:
  • context (ReportContext)

  • settings (Settings | None)

Return type:

None

help(methods=False)#

Prints message describing the fields and methods of a Flow360BaseModel.

Parameters:

methods (bool = False) – Whether to also print out information about object’s methods.

Return type:

None

Example

>>> params.help(methods=True) 
to_file(filename, **kwargs)#

Exports Flow360BaseModel instance to .json or .yaml file

Parameters:

filename (str) – Full path to the .json or .yaml or file to save the Flow360BaseModel to.

Return type:

None

Example

>>> params.to_file(filename='folder/flow360.json')