-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add utility to find SMIRNOFF parameters exercised by dataset (#11)
- Loading branch information
1 parent
665a67e
commit fcefc51
Showing
7 changed files
with
344 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pytest | ||
|
||
from descent.utilities import value_or_list_to_list | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"function_input, expected_output", | ||
[(None, None), (2, [2]), ("a", ["a"]), ([1, 2], [1, 2]), (["a", "b"], ["a", "b"])], | ||
) | ||
def test_value_or_list_to_list(function_input, expected_output): | ||
|
||
actual_output = value_or_list_to_list(function_input) | ||
assert expected_output == actual_output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from descent.utilities.utilities import value_or_list_to_list | ||
|
||
__all__ = [value_or_list_to_list] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from typing import List, TypeVar, Union, overload | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
@overload | ||
def value_or_list_to_list(value: Union[T, List[T]]) -> List[T]: | ||
... | ||
|
||
|
||
@overload | ||
def value_or_list_to_list(value: None) -> None: | ||
... | ||
|
||
|
||
def value_or_list_to_list(value): | ||
|
||
if value is None: | ||
return value | ||
|
||
return value if isinstance(value, list) else [value] |
Oops, something went wrong.