-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Input_file_handling_robustness (#107)
* Improve flexibility of input file handling * Split input dict processing from yaml read * Repair tests * Update cfspopcon/input_file_handling.py * Update cfspopcon/input_file_handling.py Co-authored-by: Christoph Hasse <[email protected]> --------- Co-authored-by: Christoph Hasse <[email protected]>
- Loading branch information
Showing
21 changed files
with
181 additions
and
58 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
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
Binary file not shown.
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
Binary file not shown.
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
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,57 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
import yaml | ||
|
||
from cfspopcon.algorithm_class import Algorithm, CompositeAlgorithm | ||
from cfspopcon.input_file_handling import read_case, process_input_dictionary | ||
|
||
|
||
@pytest.fixture | ||
def test_dict(): | ||
return dict(Q=1.0) | ||
|
||
|
||
@pytest.fixture | ||
def case_dir(): | ||
return Path(".").absolute() | ||
|
||
|
||
def test_blank_dictionary(test_dict, case_dir): | ||
process_input_dictionary(test_dict, case_dir) | ||
|
||
|
||
def test_blank_file(test_dict, tmp_path): | ||
with open(tmp_path / "input.yaml", "w") as file: | ||
yaml.dump(test_dict, file) | ||
|
||
read_case(tmp_path) | ||
|
||
|
||
def test_blank_file_with_another_suffix(test_dict, tmp_path): | ||
with open(tmp_path / "another.filetype", "w") as file: | ||
yaml.dump(test_dict, file) | ||
|
||
read_case(tmp_path / "another.filetype") | ||
|
||
|
||
def test_algorithm_read_single_from_input_file(case_dir): | ||
test_dict = dict(algorithms=["read_atomic_data"]) | ||
|
||
repr_d, algorithm, points, plots = process_input_dictionary(test_dict, case_dir) | ||
|
||
assert isinstance(algorithm, Algorithm) | ||
|
||
|
||
def test_algorithm_read_multiple_from_input_file(case_dir): | ||
test_dict = dict(algorithms=["read_atomic_data", "set_up_impurity_concentration_array"]) | ||
|
||
repr_d, algorithm, points, plots = process_input_dictionary(test_dict, case_dir) | ||
|
||
assert isinstance(algorithm, CompositeAlgorithm) | ||
|
||
|
||
def test_read_example_input_file(): | ||
example_case = Path(__file__).parents[1] / "example_cases" / "SPARC_PRD" / "input.yaml" | ||
|
||
read_case(example_case) |
Oops, something went wrong.