New settings check against valid options #39
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduces a small new feature to check that settings are valid and also adds valid options to the relevant settings' documentation.
The same way we have
settings_types
,settings_default
etc, we now have the dictionarysettings_options
for those settings that are eitherint
,str
orlist(str)
that have certain possible options. The entry for each setting insettings_options
is alist
.Example:
The convection scheme in
StepUvlm
is anint
that can be0
,2
or3
. The new dictionary would have an entry like:settings_options['convection_scheme'] = [0, 2, 3]
To implement this feature to your code:
__doc__ += settings_table.generate(settings_types, settings_default, settings_description, settings_options)
This will check the settings and raise an error if the desired option is not valid. In the case of a string, it will always accept the empty string as valid without need of adding an empty string to the list of valid options.
This is totally backwards compatible and does not need any modification unless you would like to implement these settings check.