Options
#
- class pyvbmc.vbmc.Options(default_options_path: str, evaluation_parameters: dict = None, user_options: dict = None)[source]#
This class is responsible for Options.
- Parameters:
- default_options_pathstr
The path to the default options. May be absolute or relative to this directory.
- evaluation_parametersdict
Parameters used to evaluate the options.
- user_optionsdict
User defined values to overwrite default options.
- Attributes:
- useroptionsset
This set contains all options that have set by the user, if there are none it is empty. These
useroptions
are immutable to changes usingload_options_file()
.
- eval(key: str, evaluation_parameters: dict)[source]#
Evaluate an option using evaluation_parameters if it is a callable, otherwise return the value of the option.
- Parameters:
- keystr
The name of the option.
- evaluation_parametersdict
Parameters for the options in case it is a callable. These have to match the key arguments of the callable and are ignored if it is not a callable.
- Returns:
- valobject
Value of the object which has been evaluated if it is a callable.
- classmethod init_from_existing_options(default_options_path: str, evaluation_parameters: dict = None, other: Options = None)[source]#
Initialize an options instance using default options and another options instance.
Only the user-definied options from the other object will overwrite the default options. Everything else will come from the default options.
- Parameters:
- default_options_pathstr
The path to the default options. May be absolute or relative to this directory.
- evaluation_parametersdict
Parameters used to evaluate the options.
- otherOptions
User defined values to overwrite default options.
- Returns:
- new_optionsOptions
The new options object with the values merged as described above.
- load_options_file(options_path: str, evaluation_parameters: dict = None)[source]#
Load options from an ini file and evaluate them using the specified
evaluation_parameters
.Note that strings starting with # in the .ini file act as description to the option in the following line.
- Parameters:
- options_pathstr
The path to an
options.ini
file that should be loaded. May be absolute or relative to this directory.- evaluation_parametersdict, optional
Parameters used to evaluate the options.
- validate_option_names(options_paths: list)[source]#
Check that ini files specified by the list of
options_paths
contain the option names from this options object at least once.Note that this method checks not if there are option names in files that are not in the object. After option names are validated, initialization is flagged as complete and self.is_initialized is set to True to prevent further modification of options.
- Parameters:
- options_pathslist of str
A list of paths to ini files can contain the allowed option names.
- Raises:
- ValueError
Raised when an option exists in this object but not in one of the specified ini files.