Adding further Tables
The tables that are currently supported are listed in FitBenchmarking Output. In order to add a new table, you will need to:
Give the table a name
<table_name>
. This will be used by users when selecting this output from FitBenchmarking.Create
fitbenchmarking/results_processing/<table_name>_table.py
which contains a new subclass ofTable
. The main functions to change are:- abstract Table.get_value(result)
Gets the main value to be reported in the tables for a given result
If more than one value is returned please note that the first value will be used in the default colour handling.
- Parameters:
result (FittingResult) – The result to generate the values for.
- Returns:
The value to convert to a string for the tables
- Return type:
tuple(float)
- Table.display_str(value)
Converts a value generated by
get_value()
into a string respresentation to be used in the tables. Base class implementation takes the relative and absolute values and usesself.output_string_type
as a template for the string format. This can be overridden to adequately display the results.- Parameters:
value (tuple) – Relative and absolute values
- Returns:
string representation of the value for display in the table.
- Return type:
str
Additional functions that may need to be overridden are:
- static Table.get_error_str(result, error_template='[{}]')
Get the error string for a result based on error_template This can be overridden if tables require different error formatting.
- Parameters:
result (FittingResult) – The result to get the error string for
- Returns:
A string representation of the error
- Return type:
str
- Table.get_link_str(result)
Get the link as a string for the result. This can be overridden if tables require different links.
- Parameters:
result (FittingResult) – The result to get the link for
- Returns:
The link to go to when the cell is selected
- Return type:
string
- static Table.vals_to_colour(vals, cmap, cmap_range, log_ulim)
Converts an array of values to a list of hexadecimal colour strings using logarithmic sampling from a matplotlib colourmap according to relative value.
- Parameters:
vals (list[float]) – values in the range [0, 1] to convert to colour strings
cmap (matplotlib colourmap object) – matplotlib colourmap
cmap_range (list[float], 2 elements) – values in range [0, 1] for colourmap cropping
log_ulim (float) – log10 of worst shading cutoff value
- Returns:
Colours as hex strings for each input value and Foreground colours for the text as html rgb strings e.g. ‘rgb(255, 255, 255)’
- Return type:
tuple[list[str], list[str]]
Extend the
table_type
option inOUTPUT
following the instructions in Adding new Options.Document the new table class is by setting the docstring to be the description of the table, and add to FitBenchmarking Output.
Create tests for the table in
fitbenchmarking/results_processing/tests/test_tables.py
. This is done by generating, ahead of time using the results problems constructed infitbenchmarking/results_processing/tests/test_tables.generate_test_files
, both a HTML and text table output as the expected result and adding the new table name to the global variableSORTED_TABLE_NAMES
. This will automatically run the comparison tests for the tables.