diff --git a/tests/test_distribution.py b/tests/test_distribution.py index 239400e3..fca95a2f 100644 --- a/tests/test_distribution.py +++ b/tests/test_distribution.py @@ -69,8 +69,9 @@ def test_leakage(self): def test_distribution_overrides(self): distribution = Distribution(name="", leakage=0.2) - distribution.apply_overrides({'leakage': 0}) + distribution.apply_overrides({"leakage": 0}) self.assertEqual(distribution.leakage, 0) + if __name__ == "__main__": unittest.main() diff --git a/wsimod/nodes/distribution.py b/wsimod/nodes/distribution.py index fece94d9..66baff45 100644 --- a/wsimod/nodes/distribution.py +++ b/wsimod/nodes/distribution.py @@ -4,9 +4,11 @@ @author: bdobson """ +from typing import Any, Dict + from wsimod.core import constants from wsimod.nodes.nodes import Node -from typing import Any, Dict + def decorate_leakage_set(self, f): """Decorator to extend the functionality of `f` by introducing leakage. This is @@ -126,10 +128,9 @@ def __init__(self, leakage=0, **kwargs): self.push_set_handler["default"] = self.push_set_deny self.push_check_handler["default"] = self.push_check_deny self.decorate_pull_handlers() - + def decorate_pull_handlers(self): - """Decorate handlers if there is leakage ratio. - """ + """Decorate handlers if there is leakage ratio.""" if self.leakage > 0: self.pull_set_handler["default"] = decorate_leakage_set( self, self.pull_set_handler["default"] @@ -137,21 +138,21 @@ def decorate_pull_handlers(self): self.pull_check_handler["default"] = decorate_leakage_check( self, self.pull_check_handler["default"] ) - + def apply_overrides(self, overrides: Dict[str, Any] = {}): """Apply overrides to the sewer. - - Enables a user to override any of the following parameters: + + Enables a user to override any of the following parameters: leakage. - + Args: overrides (dict, optional): Dictionary of overrides. Defaults to {}. """ - self.leakage = overrides.pop("leakage", - self.leakage) + self.leakage = overrides.pop("leakage", self.leakage) self.decorate_pull_handlers() super().apply_overrides(overrides) + class UnlimitedDistribution(Distribution): """"""