TableLogger
Documentation for TableLogger.
TableLogger.DiffXTableLogger.DiffXTableLogger.TableTableLogger.TableSetupTableLogger.differs_enoughTableLogger.differs_enoughTableLogger.fill_from_prev!TableLogger.format_table_valueTableLogger.get_column_idTableLogger.get_headerTableLogger.get_lineTableLogger.get_valueTableLogger.init_log_tableTableLogger.init_log_tableTableLogger.print_headerTableLogger.print_lineTableLogger.set_value!TableLogger.shall_print_lineTableLogger.update_for_new_row
TableLogger.DiffX — TypeDiffX{V,B}Can be used to specify the absolute difference which makes the given value different enough from the previous value to print a new line. As an example if the last value is DiffX(5, 10) and the new value is DiffX(5, 12) the change is not significant enough. If the next value however is DiffX(5, 15) then the value is different enough from the last printed value 10. Therefore a new line is printed.
TableLogger.DiffX — MethodDiffX(by)Create an anonymous function with something like Diffd1 = DiffX(0.1) to be able to use Diffd1(10.0) instead of DiffX(0.1, 10.0).
TableLogger.Table — Typemutable struct TableStores the TableSetup as well as the current and previous values
TableLogger.TableSetup — Typestruct TableSetupStores information about the columns of the table by storing: ids, names, widths, alignments and precision
TableLogger.differs_enough — Methoddiffers_enough(value, prev_value)Return true if the value is significantly different from prev_value. In this default case simply return true if they are different. Provide your own differs_enough function by dispatching on both values.
TableLogger.differs_enough — Methoddiffers_enough(value::DiffX, prev_value::DiffX)Check whether two DiffX values differ enough from each other.
TableLogger.fill_from_prev! — Methodfill_from_prev!(table::Table)If a value isn't given by a new called set_value! since the last call to print_line the previous value will be used. This function overwrites table.current_values to set unassigned values to table.prev_values.
TableLogger.format_table_value — Methodformat_table_value(width::Int, value; default_precision=2)Format the table value using the given width and value.
For val::Real
- return a string representation that fits in the width and return "<<" if val is smaller than 0 but can't be represented or ">>" when it's bigger than 0.
For val::Integer
- return simply the string representation and
t.l.if it doesn't fit
For all others:
- return simply the string representation and
t.l.if it doesn't fit
TableLogger.get_column_id — Methodget_column_id(table::Table, sym::Symbol)Return the column id of the given symbol sym. If the symbol doesn't exist throw an error.
TableLogger.get_header — Methodget_header(table::Table)Return the header string of the Table including ====== as the second line
TableLogger.get_line — Methodget_line(table::Table)Get the next line of the table by using table.current_values. Call format_table_value to format each value and use the alignments to create the line such that it fits to get_header.
TableLogger.get_value — Methodget_value(d::DiffX)Taking the value of DiffX to represent it in the table.
TableLogger.init_log_table — Methodinit_log_table(columns::NamedTuple...; width=20, alignment=:center, precision=2)Initialize the table structure by a list of information for each column.
Example
table = init_log_table(
(id=:open_nodes, name="#Open", width=30),
(id=:closed_nodes, name="#Closed"),
)Would create a table with two columns named #Open and #Closed and the width of #Open is 30. The default width of 20 is used for the closed nodes and both tables use the default alignment :center.
table = init_log_table(
(id=:open_nodes, name="#Open", width=30),
(id=:closed_nodes, name="#Closed");
alignment = :left
)In this case the default alignment is changed to :left.
TableLogger.init_log_table — Methodinit_log_table(ids::Vector{Symbol}, names::Vector{String}, widths::Vector{Int}, alignments::Vector{Symbol}, precisions::Vector{Int})Initialize the table structure with a vector of ids, names, widths, alignments and precisions.
TableLogger.print_header — Methodprint_header(table::Table)Print the header of the given table. Calls get_header.
TableLogger.print_line — Methodprint_line(table::Table; force=false)Print the new line of the table if it differs enough from the previous line or if force = true. If the new line gets printed set the prev_values to current_values and the current_values to an nothing.
TableLogger.set_value! — Methodset_value!(table::Table, column::Symbol, value)Set the current value of the given column to value
TableLogger.shall_print_line — Methodshall_print_line(table::Table; force=false)Return whether the new line shall be printed. If force = true return true immediately. Otherwise check if at least one value differs enough from the previous value by calling differs_enough.
TableLogger.update_for_new_row — Methodupdate_for_new_row(table)Set the previous values to current_values by using deepcopy and set all current_values to nothing.