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

Default keyword arguments result in error #382

Closed
lilyminium opened this issue Sep 18, 2021 · 1 comment · Fixed by #384
Closed

Default keyword arguments result in error #382

lilyminium opened this issue Sep 18, 2021 · 1 comment · Fixed by #384

Comments

@lilyminium
Copy link
Contributor

In generate_default_metadata, the default parameter_gradient_keys=None, results in an error.

@staticmethod
def generate_default_metadata(
physical_property,
force_field_path,
parameter_gradient_keys=None,
target_uncertainty=None,
):

~/anaconda3/envs/polymetrizer/lib/python3.9/site-packages/openff/evaluator/workflow/workflow.py in generate_default_metadata(physical_property, force_field_path, parameter_gradient_keys, target_uncertainty)
    684         # Find only those gradient keys which will actually be relevant to the
    685         # property of interest
--> 686         relevant_gradient_keys = Workflow._find_relevant_gradient_keys(
    687             physical_property.substance, force_field_path, parameter_gradient_keys
    688         )

~/anaconda3/envs/polymetrizer/lib/python3.9/site-packages/openff/evaluator/workflow/workflow.py in _find_relevant_gradient_keys(substance, force_field_path, parameter_gradient_keys)
    568 
    569         # noinspection PyTypeChecker
--> 570         if parameter_gradient_keys == UNDEFINED or len(parameter_gradient_keys) == 0:
    571             return []
    572 

TypeError: object of type 'NoneType' has no len()

Ideally default values for functions should be ones that "just work". I'd suggest passing in parameter_gradient_keys=UNDEFINED.

@SimonBoothroyd
Copy link
Contributor

Thanks for catching this - a PR with the fix would be welcome!

SimonBoothroyd added a commit to lilyminium/openff-evaluator that referenced this issue Oct 5, 2021
SimonBoothroyd pushed a commit that referenced this issue Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants