-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert yaml configuration hyphens to underscores (#113)
Co-authored-by: ElliottKasoar <ElliottKasoar@users.noreply.github.com>
- Loading branch information
1 parent
9f9ebc1
commit f4f9d01
Showing
9 changed files
with
133 additions
and
31 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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
struct_path: "NaCl.cif" | ||
out_file: "NaCl-results.xyz" | ||
opt_kwargs: | ||
struct: "NaCl.cif" | ||
out: "NaCl-results.xyz" | ||
opt-kwargs: | ||
alpha: 100 |
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
ensemble: "nvt" | ||
temp: 200 | ||
minimize-kwargs: | ||
filter-kwargs: | ||
hydrostatic-strain: True |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
struct_path: "NaCl.cif" | ||
struct: "NaCl.cif" | ||
properties: | ||
- "energy" | ||
out_file: "NaCl-results.xyz" | ||
calc_kwargs: | ||
out: "NaCl-results.xyz" | ||
calc-kwargs: | ||
model: "small" | ||
read_kwargs: | ||
read-kwargs: | ||
index: ":" |
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,48 @@ | ||
"""Test utility functions.""" | ||
|
||
from pathlib import Path | ||
|
||
from janus_core.utils import dict_paths_to_strs, dict_remove_hyphens | ||
|
||
|
||
def test_dict_paths_to_strs(): | ||
"""Test Paths are converted to strings.""" | ||
dictionary = { | ||
"key1": Path("/example/path"), | ||
"key2": { | ||
"key3": Path("another/example"), | ||
"key4": "example", | ||
}, | ||
} | ||
|
||
# Check Paths are present | ||
assert isinstance(dictionary["key1"], Path) | ||
assert isinstance(dictionary["key2"]["key3"], Path) | ||
assert not isinstance(dictionary["key1"], str) | ||
|
||
dict_paths_to_strs(dictionary) | ||
|
||
# Check Paths are now strings | ||
assert isinstance(dictionary["key1"], str) | ||
assert isinstance(dictionary["key2"]["key3"], str) | ||
|
||
|
||
def test_dict_remove_hyphens(): | ||
"""Test hyphens are replaced with underscores.""" | ||
dictionary = { | ||
"key-1": "value_1", | ||
"key-2": { | ||
"key-3": "value-3", | ||
"key-4": 4, | ||
"key_5": 5.0, | ||
"key6": {"key-7": "value7"}, | ||
}, | ||
} | ||
dictionary = dict_remove_hyphens(dictionary) | ||
|
||
# Check hyphens are now strings | ||
assert dictionary["key_1"] == "value_1" | ||
assert dictionary["key_2"]["key_3"] == "value-3" | ||
assert dictionary["key_2"]["key_4"] == 4 | ||
assert dictionary["key_2"]["key_5"] == 5.0 | ||
assert dictionary["key_2"]["key6"]["key_7"] == "value7" |