Adding new Options¶
Default options are set in Options
.
These can be changed using an .ini formatted file
(see here). FitBenchmarking Options gives examples of how this is currently implemented in
FitBenchmarking.
To add a new option to one of the five sections FITTING
, MINIMIZERS
, PLOTTING
and LOGGING
, follow the steps below.
We’ll illustrate the steps using <SECTION>
, which could be any of the
sections above.
Amend the dictionary
DEFAULT_<SECTION>
inOptions
to include any new default options.If the option amended is to be checked for validity, add accepted option values to the
VALID_<SECTION>
dictionary inOptions
.Using the
read_value()
function, add your new option to the class, following the examples already inOptions
. The syntax of this function is:-
Options.
read_value
(func, option) Helper function which loads in the value
Parameters: - func (callable) – configparser function
- option (str) – option to be read for file
Returns: value of the option
Return type: list/str/int/bool
-
Add tests in the following way:
- Each of the sections has it’s own test file, for example,
test_option_fitting
has tests for theFITTING
section. - Add default tests to the class called
<SECTION>OptionTests
. - Add user defined tests to the class called
User<SECTION>OptionTests
. These should check that the user added option is valid and raise anOptionsError
if not.
- Each of the sections has it’s own test file, for example,
Add relevant documentation for the new option in FitBenchmarking Options.
Adding new Sections is also possible. To do this you’ll need to extend
VALID_SECTIONS
with the new section, and follow the same structure as the
other SECTIONS.