Skip to content

Commit

Permalink
autoformat: isort & black
Browse files Browse the repository at this point in the history
  • Loading branch information
MRVermeulenDeltares committed Apr 26, 2024
1 parent 8f24b09 commit a45cb2f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
38 changes: 27 additions & 11 deletions hydrolib/core/dimr/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,25 +362,37 @@ def _post_init_load(self) -> None:

def _save(self, save_settings: ModelSaveSettings) -> None:
dimr_as_dict = self.dict()
dimr_as_dict = self.update_dimr_dictonary_with_adjusted_fmcomponent_values(dimr_as_dict)
dimr_as_dict = self.update_dimr_dictonary_with_adjusted_fmcomponent_values(
dimr_as_dict
)
self._serialize(dimr_as_dict, save_settings)

def update_dimr_dictonary_with_adjusted_fmcomponent_values(self, dimr_as_dict : Dict):
def update_dimr_dictonary_with_adjusted_fmcomponent_values(
self, dimr_as_dict: Dict
):
fmcomponents = [
item for item in self.component if isinstance(item, FMComponent)
]

list_of_fmcomponents_as_dict = self._get_list_of_updated_fm_components(fmcomponents)
dimr_as_dict = self._update_dimr_dictionary(dimr_as_dict, list_of_fmcomponents_as_dict)

list_of_fmcomponents_as_dict = self._get_list_of_updated_fm_components(
fmcomponents
)
dimr_as_dict = self._update_dimr_dictionary(
dimr_as_dict, list_of_fmcomponents_as_dict
)
return dimr_as_dict

def _update_dimr_dictionary(self, dimr_as_dict : Dict, list_of_fm_components_as_dict : List[Dict]) -> Dict:
def _update_dimr_dictionary(
self, dimr_as_dict: Dict, list_of_fm_components_as_dict: List[Dict]
) -> Dict:
if len(list_of_fm_components_as_dict) > 0:
dimr_as_dict.update({"component": list_of_fm_components_as_dict})

return dimr_as_dict

def _get_list_of_updated_fm_components(self, fmcomponents : List[FMComponent]) -> List[Dict]:
def _get_list_of_updated_fm_components(
self, fmcomponents: List[FMComponent]
) -> List[Dict]:
list_of_fm_components_as_dict = []
for fmcomponent in fmcomponents:
if fmcomponent is None or fmcomponent.process is None:
Expand All @@ -393,12 +405,16 @@ def _get_list_of_updated_fm_components(self, fmcomponents : List[FMComponent]) -
str(i) for i in range(fmcomponent.process)
)

fmcomponent_as_dict = self._update_component_dictonary(fmcomponent, fmcomponent_process_value)
fmcomponent_as_dict = self._update_component_dictonary(
fmcomponent, fmcomponent_process_value
)
list_of_fm_components_as_dict.append(fmcomponent_as_dict)

return list_of_fm_components_as_dict

def _update_component_dictonary(self, fmcomponent : FMComponent, fmcomponent_process_value: str) -> Dict:
def _update_component_dictonary(
self, fmcomponent: FMComponent, fmcomponent_process_value: str
) -> Dict:
fmcomponent_as_dict = fmcomponent.dict()
fmcomponent_as_dict.update({"process": fmcomponent_process_value})
return fmcomponent_as_dict
Expand Down
2 changes: 1 addition & 1 deletion tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ def test_dimr_with_fmcomponent_saving_process(
assert any(
line.strip() == line_to_check for line in file
), f"File {save_location} does not contain the line: {line_to_check}"

@pytest.mark.parametrize(
"input_process, expected_process_format",
[
Expand Down

0 comments on commit a45cb2f

Please sign in to comment.