From f4a5b561b73f1d846a8725c12622fe2d21043053 Mon Sep 17 00:00:00 2001 From: liuly12 Date: Fri, 26 Jul 2024 14:38:40 +0100 Subject: [PATCH] pre-commit reformatted --- tests/test_nodes.py | 15 +++++++++------ wsimod/nodes/nodes.py | 9 +++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/test_nodes.py b/tests/test_nodes.py index 311bf428..2efafbae 100644 --- a/tests/test_nodes.py +++ b/tests/test_nodes.py @@ -660,22 +660,25 @@ def test_decay_queue(self): "temperature": ((5 * 10) + (15 * 1)) / 6, } self.assertDictAlmostEqual(d4, tank.storage, 15) - + def test_node_overrides(self): node = Node(name="", data_input_dict={("temperature", 1): 15}) # check the format of dict - new_data_input_dict = {("temperature", 1): 10, - ("temperature", 2): 20, - } - node.apply_overrides({'data_input_dict': new_data_input_dict}) + new_data_input_dict = { + ("temperature", 1): 10, + ("temperature", 2): 20, + } + node.apply_overrides({"data_input_dict": new_data_input_dict}) self.assertDictEqual(node.data_input_dict, new_data_input_dict) # check the format of str new_data_input_dict = "example_data_input_dict.csv.gz" - node.apply_overrides({'data_input_dict': new_data_input_dict}) + node.apply_overrides({"data_input_dict": new_data_input_dict}) from wsimod.orchestration.model import read_csv + new_data_input_dict = read_csv(new_data_input_dict) self.assertDictEqual(node.data_input_dict, new_data_input_dict) print(dict(list(node.data_input_dict.items())[:5])) + if __name__ == "__main__": unittest.main() diff --git a/wsimod/nodes/nodes.py b/wsimod/nodes/nodes.py index 0064c049..7b0b8b25 100644 --- a/wsimod/nodes/nodes.py +++ b/wsimod/nodes/nodes.py @@ -90,16 +90,17 @@ def apply_overrides(self, overrides: Dict[str, Any] = {}) -> None: """ # overrides data_input_dict from wsimod.orchestration.model import read_csv - content = overrides.pop('data_input_dict', self.data_input_dict) + + content = overrides.pop("data_input_dict", self.data_input_dict) if isinstance(content, str): self.data_input_dict = read_csv(content) elif isinstance(content, dict): self.data_input_dict = content elif not content: - pass + pass else: - print('ERROR: not recognised format for data_input_dict') - + print("ERROR: not recognised format for data_input_dict") + if len(overrides) > 0: print(f"No override behaviour defined for: {overrides.keys()}")