Skip to content

Commit

Permalink
pre-commit reformatted
Browse files Browse the repository at this point in the history
  • Loading branch information
liuly12 committed Jul 26, 2024
1 parent 111f20a commit f4a5b56
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
15 changes: 9 additions & 6 deletions tests/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
9 changes: 5 additions & 4 deletions wsimod/nodes/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}")

Expand Down

0 comments on commit f4a5b56

Please sign in to comment.