Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New settings check against valid options #39

Merged
merged 6 commits into from Nov 25, 2019
Merged

Conversation

ngoiz
Copy link
Collaborator

@ngoiz ngoiz commented Nov 25, 2019

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 dictionary settings_options for those settings that are either int, str or list(str) that have certain possible options. The entry for each setting in settings_options is a list.

Example:
The convection scheme in StepUvlm is an int that can be 0, 2 or 3. The new dictionary would have an entry like:
settings_options['convection_scheme'] = [0, 2, 3]

To implement this feature to your code:

  • Documentation table:
    __doc__ += settings_table.generate(settings_types, settings_default, settings_description, settings_options)
  • Settings to custom settings:
    settings.to_custom_types(self.settings,
                                 self.settings_types,
                                 self.settings_default,
                                 self.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.

@fonsocarre fonsocarre merged commit b512e36 into rc-1.0.2 Nov 25, 2019
@fonsocarre fonsocarre deleted the dev_options branch November 25, 2019 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants