iode.Table
- class iode.Table(nb_columns: int = 2, table_title: str = '', lecs_or_vars: str | List[str] = None, lines_titles: List[str] = None, mode: bool = False, files: bool = False, date: bool = False)[source]
IODE tables are objects designed to present variables and scalars (results or data) in the form of tables of figures or graphs. They are defined as a set of lines of various types (title, formula, dividers, etc.). These lines contain formulas that will be calculated when printed, based on the values in the series, for example after a simulation. IODE tables therefore do not contain numbers, but rather the formulas that will be used to calculate the values to be printed in the tables.
Each line in a table has a set of attributes, the most important of which is its type. This type determines how the line will be printed, and the possible contents of the line definition. The other attributes concern the type of characters to be used when printing and the framing of the line. The table also contains graphic attributes that concern the layout of the graphic that will eventually be built with this table.
- Parameters:
- nb_columnsint
The number of columns in the IODE table. Defaults to 2.
- table_titlestr, optional
The title of the table or the name of the IODE Comment that must become the title. Defaults to empty.
- lecs_or_varsstr or List[str], optional
The LEC formulas of the lines or the list of variable names. If it represents a list of variables, the associated line title for each variable will be the IODE comment with the same name if it exists, the name of the variable otherwise.
- lines_titles: list(str), optional
Titles of the lines. If None, the arguments ‘lecs_or_vars’ is assumed to represents a list of variables.
- modebool, optional
Whether or not to add a ‘MODE’ line to the table. Defaults to False.
- filesbool, optional
Whether or not to add a ‘FILES’ line to the table. This line contains the files used to display the values of the computed table. Defaults to False.
- datebool, optional
Whether or not to add a ‘DATE’ line to the table. This line contains the date when the table has been computed. Defaults to False.
- Attributes:
- title: str
The title of the table.
- ymin: float
Minimum values on the Y axis. If data falls outside these values, the axis scale adapts to the data. The value \(NA\) can be set for ymin and/or ymax: in this case, the graphics program will calculate an optimum scale value.
- ymax: float
Maximum values on the Y axis. If data falls outside these values, the axis scale adapts to the data. The value \(NA\) can be set for ymin and/or ymax: in this case, the graphics program will calculate an optimum scale value.
- gridx: TableGraphGrid
X-grid options: MAJOR, NONE or MINOR.
- gridy: TableGraphGrid
Y-grid options: MAJOR, NONE or MINOR.
- graph_axis: TableGraphAxis
Y-axis scale: VALUES, LOG, SEMILOG or PERCENT.
- graph_alignment: TableGraphAlign
Graph alignment: LEFT, CENTER or RIGHT.
- box: bool
Whether the graph should be boxed.
- shadow: bool
Whether or not to place a shadow behind the chart.
Methods
compute(generalized_sample[, extra_files, ...])Compute the values corresponding to LEC expressions in cells.
copy()Return a copy of the current Table.
index(key)Return the index of the line containing the string key.
insert(index, value)Insert a new line in the table.
get_instance
update_owner_database
- Returns:
- Table
Examples
>>> from iode import SAMPLE_DATA_DIR >>> from iode import Table, comments, lists, variables >>> comments.load(f"{SAMPLE_DATA_DIR}/fun.cmt") Loading .../fun.cmt 317 objects loaded >>> lists.load(f"{SAMPLE_DATA_DIR}/fun.lst") Loading .../fun.lst 17 objects loaded >>> variables.load(f"{SAMPLE_DATA_DIR}/fun.var") Loading .../fun.var 394 objects loaded
>>> # empty table >>> table = Table() >>> table DIVIS | 1 | TITLE | ----- | -------- CELL | | "#S" ----- | -------- nb lines: 4 nb columns: 2 language: 'ENGLISH' gridx: 'MAJOR' gridy: 'MAJOR' graph_axis: 'VALUES' graph_alignment: 'LEFT'
>>> # left column = line title >>> # right column = variable or LEC expression >>> table_title = "Table example with titles on the left and LEC expressions on the right" >>> # content of the left column >>> lines_titles = ["GOSG:", "YDTG:", "DTH:", "DTF:", "IT:", "YSSG+COTRES:", "RIDG:", "OCUG:"] >>> # content of the right column >>> lines_lecs = ["GOSG", "YDTG", "DTH", "DTF", "IT", "YSSG+COTRES", "RIDG", "OCUG"] >>> table = Table(2, table_title, lines_lecs, lines_titles, True, True, True) >>> table DIVIS | 1 | TITLE | "Table example with titles on the left and LEC expressions on the right" ----- | ------------------------------------------------------------------------ CELL | | "#S" ----- | ------------------------------------------------------------------------ CELL | "GOSG:" | GOSG CELL | "YDTG:" | YDTG CELL | "DTH:" | DTH CELL | "DTF:" | DTF CELL | "IT:" | IT CELL | "YSSG+COTRES:" | YSSG+COTRES CELL | "RIDG:" | RIDG CELL | "OCUG:" | OCUG ----- | ------------------------------------------------------------------------ MODE | FILES | DATE | nb lines: 16 nb columns: 2 language: 'ENGLISH' gridx: 'MAJOR' gridy: 'MAJOR' graph_axis: 'VALUES' graph_alignment: 'LEFT'
>>> # if the argument 'lines_titles' is not used, the argument 'lecs_or_vars' represents >>> # a list of variables. >>> table_title = "Table example with variables only" >>> # the element '$ENVI' of 'lines_vars' below represents the IODE list 'ENVI' and will >>> # be automatically expanded to its contained variables when passed to the Table constructor >>> lines_vars = ["GOSG", "YDTG", "DTH", "DTF", "IT", "YSSG", "COTRES", "RIDG", "OCUG", "$ENVI"] >>> table = Table(2, table_title, lines_vars, mode=True, files=True, date=True) >>> table DIVIS | 1 | TITLE | "Table example with variables only" ----- | ------------------------------------------------------------------------------ CELL | | "#S" ----- | ------------------------------------------------------------------------------ CELL | "Bruto exploitatie-overschot: overheid (= afschrijvingen)." | GOSG CELL | "Overheid: geïnde indirecte belastingen." | YDTG CELL | "Totale overheid: directe belasting van de gezinnen." | DTH CELL | "Totale overheid: directe vennootschapsbelasting." | DTF CELL | "Totale indirecte belastingen." | IT CELL | "Globale overheid: ontvangen sociale zekerheidsbijdragen." | YSSG CELL | "Cotisation de responsabilisation." | COTRES CELL | "Overheid: inkomen uit vermogen." | RIDG CELL | "Globale overheid: saldo van de ontvangen lopendeoverdrachten." | OCUG CELL | "Wisselkoers van de USD t.o.v. de BEF (jaargemiddelde)." | EX CELL | "Index wereldprijs - invoer van niet-energieprodukten, inUSD." | PWMAB CELL | "Index wereldprijs - invoer van diensten, in USD." | PWMS CELL | "Index wereldprijs - uitvoer van niet-energieprodukten, inUSD." | PWXAB CELL | "Index wereldprijs - uitvoer van diensten, in USD." | PWXS CELL | "Indicator van het volume van de wereldvraag naar goederen,1985=1." | QWXAB CELL | "Indicator van het volume van de wereldvraag naar diensten,1985=1." | QWXS CELL | "Brent olieprijs (USD per barrel)." | POIL CELL | "Totale beroepsbevolking (jaargemiddelde)." | NATY CELL | "TFPFHP_" | TFPFHP_ ----- | ------------------------------------------------------------------------------ MODE | FILES | DATE | nb lines: 27 nb columns: 2 language: 'ENGLISH' gridx: 'MAJOR' gridy: 'MAJOR' graph_axis: 'VALUES' graph_alignment: 'LEFT'
>>> # variables or LEC expressions can be also passed as a single string >>> lines_vars = "GOSG;YDTG;DTH;DTF;IT;YSSG;COTRES;RIDG;OCUG;$ENVI" >>> table_title = "Table example with all variables passed as a single string" >>> table = Table(2, table_title, lines_vars, mode=True, files=True, date=True) >>> table DIVIS | 1 | TITLE | "Table example with all variables passed as a single string" ----- | ------------------------------------------------------------------------------ CELL | | "#S" ----- | ------------------------------------------------------------------------------ CELL | "Bruto exploitatie-overschot: overheid (= afschrijvingen)." | GOSG CELL | "Overheid: geïnde indirecte belastingen." | YDTG CELL | "Totale overheid: directe belasting van de gezinnen." | DTH CELL | "Totale overheid: directe vennootschapsbelasting." | DTF CELL | "Totale indirecte belastingen." | IT CELL | "Globale overheid: ontvangen sociale zekerheidsbijdragen." | YSSG CELL | "Cotisation de responsabilisation." | COTRES CELL | "Overheid: inkomen uit vermogen." | RIDG CELL | "Globale overheid: saldo van de ontvangen lopendeoverdrachten." | OCUG CELL | "Wisselkoers van de USD t.o.v. de BEF (jaargemiddelde)." | EX CELL | "Index wereldprijs - invoer van niet-energieprodukten, inUSD." | PWMAB CELL | "Index wereldprijs - invoer van diensten, in USD." | PWMS CELL | "Index wereldprijs - uitvoer van niet-energieprodukten, inUSD." | PWXAB CELL | "Index wereldprijs - uitvoer van diensten, in USD." | PWXS CELL | "Indicator van het volume van de wereldvraag naar goederen,1985=1." | QWXAB CELL | "Indicator van het volume van de wereldvraag naar diensten,1985=1." | QWXS CELL | "Brent olieprijs (USD per barrel)." | POIL CELL | "Totale beroepsbevolking (jaargemiddelde)." | NATY CELL | "TFPFHP_" | TFPFHP_ ----- | ------------------------------------------------------------------------------ MODE | FILES | DATE | nb lines: 27 nb columns: 2 language: 'ENGLISH' gridx: 'MAJOR' gridy: 'MAJOR' graph_axis: 'VALUES' graph_alignment: 'LEFT'
- __init__(nb_columns: int = 2, table_title: str = '', lecs_or_vars: str | List[str] = None, lines_titles: List[str] = None, mode: bool = False, files: bool = False, date: bool = False) Self[source]
Methods
__init__([nb_columns, table_title, ...])compute(generalized_sample[, extra_files, ...])Compute the values corresponding to LEC expressions in cells.
copy()Return a copy of the current Table.
get_instance()index(key)Return the index of the line containing the string key.
insert(index, value)Insert a new line in the table.
update_owner_database()Attributes
Whether the graph should be boxed.
Get the list of coefficients (scalars) associated with all cells of type 'LEC' of the table.
Returns the divider line of the table.
Graph alignment of the table.
Graph axis of the table allows you to select the type of axis:
The gridx value of the table offers a choice of three X-grid options:
The gridy value of the table offers a choice of three Y-grid options:
Language.
Whether or not to place a shadow behind the chart.
Title of the table.
Get the list of variables associated with all cells of the type 'LEC' of the table.
Maximum values on the Y axis.
Minimum values on the Y axis.