diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2db096f8..f16cbfce 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -33,7 +33,7 @@ jobs: steps: - name: Download sdist artifact - uses: actions/download-artifact@v7 + uses: actions/download-artifact@v8 with: name: artifact path: dist diff --git a/docs/demo/scripts/customise_interactions.py b/docs/demo/scripts/customise_interactions.py index f494c8c9..1839ccd8 100644 --- a/docs/demo/scripts/customise_interactions.py +++ b/docs/demo/scripts/customise_interactions.py @@ -36,7 +36,6 @@ from wsimod.nodes.sewer import Sewer - my_sewer = Sewer(name="mr_sewer") print(my_sewer.push_set_handler) diff --git a/tests/run_all_tests.py b/tests/run_all_tests.py index aa4ff3f2..ffc8491b 100644 --- a/tests/run_all_tests.py +++ b/tests/run_all_tests.py @@ -4,6 +4,7 @@ @author: Barney """ + import os import unittest diff --git a/tests/test_land.py b/tests/test_land.py index 0567390b..43b6b150 100644 --- a/tests/test_land.py +++ b/tests/test_land.py @@ -78,7 +78,7 @@ def test_atmospheric_dep(self): d1 = {"ammonia": 1, "nitrate": 4, "phosphate": 2, "volume": 0, "temperature": 0} d2 = {"volume": 0, "temperature": 0, "phosphate": 0} - (r1, r2) = surface.atmospheric_deposition() + r1, r2 = surface.atmospheric_deposition() self.assertDictAlmostEqual(d1, r1) self.assertDictAlmostEqual(d2, r2) @@ -93,7 +93,7 @@ def test_precip_dep(self): d1 = {"ammonia": 1, "nitrate": 4, "phosphate": 2, "volume": 0, "temperature": 0} d2 = {"volume": 0, "temperature": 0, "phosphate": 0} - (r1, r2) = surface.precipitation_deposition() + r1, r2 = surface.precipitation_deposition() self.assertDictAlmostEqual(d1, r1) self.assertDictAlmostEqual(d2, r2) @@ -164,7 +164,7 @@ def test_simple_dep(self): surface = Surface(pollutant_load=d1, area=1) - (in_, out_) = surface.simple_deposition() + in_, out_ = surface.simple_deposition() d2 = {"volume": 0, "temperature": 0, "phosphate": 0} self.assertDictAlmostEqual(d1, in_) @@ -193,7 +193,7 @@ def test_urban_precip(self): d1 = {"volume": 0.1 * 1.5, "temperature": 0, "phosphate": 0} d2 = {"phosphate": 0, "volume": 0.01 * 1.5 * 0.9, "temperature": 0} d3 = {"phosphate": 0, "temperature": 10, "volume": (0.1 - 0.01 * 0.9) * 1.5} - (r1, r2) = surface.precipitation_evaporation() + r1, r2 = surface.precipitation_evaporation() self.assertDictAlmostEqual(d1, r1, 17) self.assertDictAlmostEqual(d2, r2, 17) self.assertDictAlmostEqual(d3, surface.storage, 17) @@ -206,7 +206,7 @@ def test_urban_precip(self): "temperature": 10, "volume": (0.1 - (0.01 + 0.02) * 0.9) * 1.5, } - (r1, r2) = surface.precipitation_evaporation() + r1, r2 = surface.precipitation_evaporation() self.assertDictAlmostEqual(d3, r1, 17) self.assertDictAlmostEqual(d4, r2, 17) self.assertDictAlmostEqual(d5, surface.storage, 17) @@ -279,7 +279,7 @@ def test_ihacres1(self): node.t = 1 - (r1, r2) = surface.ihacres() + r1, r2 = surface.ihacres() d1 = {"volume": 0.1 * 1.5, "phosphate": 0, "temperature": 0} @@ -350,7 +350,7 @@ def test_ihacres2(self): node.t = 1 - (r1, r2) = surface.ihacres() + r1, r2 = surface.ihacres() evaporation_ = ( 0.01 @@ -407,7 +407,7 @@ def test_ihacres3(self): node.t = 1 - (r1, r2) = surface.ihacres() + r1, r2 = surface.ihacres() d1 = {"volume": 0.1 * 1.5, "phosphate": 0, "temperature": 0} @@ -472,7 +472,7 @@ def test_perv_route(self): surface.subsurface_flow = d2 surface.percolation = d3 - (r1, r2) = surface.route() + r1, r2 = surface.route() self.assertDictAlmostEqual(d4, r1) self.assertDictAlmostEqual(d4, r2) self.assertDictAlmostEqual(d1, land.surface_runoff.storage) @@ -508,7 +508,7 @@ def test_soil_temp(self): "phosphate": 0.2, } - (r1, r2) = surface.calculate_soil_temperature() + r1, r2 = surface.calculate_soil_temperature() self.assertDictAlmostEqual(d1, r1) self.assertDictAlmostEqual(d1, r2) self.assertDictAlmostEqual(d2, surface.storage, 14) @@ -727,7 +727,7 @@ def test_fertiliser(self): node.monthyear = 1 surface.parent = node - (r1, r2) = surface.fertiliser() + r1, r2 = surface.fertiliser() d1 = surface.empty_vqip() @@ -752,7 +752,7 @@ def test_manure(self): node.monthyear = 1 surface.parent = node - (r1, r2) = surface.manure() + r1, r2 = surface.manure() d1 = surface.empty_vqip() @@ -844,7 +844,7 @@ def test_soil_pool(self): nut_p = surface.nutrient_pool cf = nut_p.temperature_dependence_factor * nut_p.soil_moisture_dependence_factor - (r1, r2) = surface.soil_pool_transformation() + r1, r2 = surface.soil_pool_transformation() fast_ = {"N": isoil["org-nitrogen"], "P": isoil["org-phosphorus"]} # original dissolved_inorganic_ = { @@ -919,7 +919,7 @@ def test_crop_uptake(self): surface.days_after_sow = date.dayofyear - surface.sowing_day _ = surface.calc_crop_cover() - (r1, r2) = surface.calc_crop_uptake() + r1, r2 = surface.calc_crop_uptake() d1 = surface.empty_vqip() self.assertDictAlmostEqual(r1, d1) @@ -956,7 +956,7 @@ def test_erosion1(self): node.t = date surface.parent = node _ = surface.ihacres() - (r1, r2) = surface.erosion() + r1, r2 = surface.erosion() d1 = surface.empty_vqip() self.assertDictAlmostEqual(d1, r2) d1["phosphate"] = 0.0019497135091285024 @@ -979,7 +979,7 @@ def test_erosion2(self): node.t = date surface.parent = node _ = surface.ihacres() - (r1, r2) = surface.erosion() + r1, r2 = surface.erosion() d1 = surface.empty_vqip() self.assertDictAlmostEqual(d1, r2) d1["phosphate"] = 1.0244298083948e-06 @@ -1002,7 +1002,7 @@ def test_erosion3(self): node.t = date surface.parent = node _ = surface.ihacres() - (r1, r2) = surface.erosion() + r1, r2 = surface.erosion() d1 = surface.empty_vqip() self.assertDictAlmostEqual(d1, r2) d1["phosphate"] = 8.3285749289e-09 @@ -1014,7 +1014,7 @@ def test_denitrification(self): constants.set_default_pollutants() surface, ivol, isoil = self.create_growing_surface() surface.calc_temperature_dependence_factor() - (r1, r2) = surface.denitrification() + r1, r2 = surface.denitrification() d1 = surface.empty_vqip() self.assertDictAlmostEqual(d1, r1) d1["nitrate"] = 0.03295446191742672 @@ -1024,7 +1024,7 @@ def test_desorption(self): constants.set_default_pollutants() surface, ivol, isoil = self.create_growing_surface() surface.nutrient_pool.adsorbed_inorganic_pool.storage["P"] = 1e6 - (r1, r2) = surface.adsorption() + r1, r2 = surface.adsorption() d1 = surface.empty_vqip() self.assertDictAlmostEqual(d1, r2) d1["phosphate"] = 29534.602916697728 @@ -1054,7 +1054,7 @@ def test_adsorption(self): surface.fertiliser() - (r1, r2) = surface.adsorption() + r1, r2 = surface.adsorption() d1 = surface.empty_vqip() self.assertDictAlmostEqual(d1, r1) d1["phosphate"] = 1.5761692429741743 diff --git a/tests/test_model.py b/tests/test_model.py index bfb95b80..fccdcaec 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -4,6 +4,7 @@ @author: Barney """ + import os import pytest import unittest diff --git a/wsimod/core/constants.py b/wsimod/core/constants.py index d529bcc2..7b846e70 100644 --- a/wsimod/core/constants.py +++ b/wsimod/core/constants.py @@ -3,6 +3,7 @@ @author: bdobson """ + from wsimod.core import constants M3_S_TO_ML_D = 86.4 diff --git a/wsimod/core/core.py b/wsimod/core/core.py index d73b606d..7c429a19 100644 --- a/wsimod/core/core.py +++ b/wsimod/core/core.py @@ -5,6 +5,7 @@ Converted to totals on Thur Apr 21 2022 """ + from math import log10 from wsimod.core import constants diff --git a/wsimod/demo/create_oxford.py b/wsimod/demo/create_oxford.py index 7dbb9724..4d789c51 100644 --- a/wsimod/demo/create_oxford.py +++ b/wsimod/demo/create_oxford.py @@ -3,6 +3,7 @@ @author: Barney """ + import os import re diff --git a/wsimod/nodes/catchment.py b/wsimod/nodes/catchment.py index 640d2383..be0bf29d 100644 --- a/wsimod/nodes/catchment.py +++ b/wsimod/nodes/catchment.py @@ -5,6 +5,7 @@ Converted to totals on 2022-05-03 """ + from wsimod.core import constants from wsimod.nodes.nodes import Node diff --git a/wsimod/nodes/demand.py b/wsimod/nodes/demand.py index 5778186a..4384129f 100644 --- a/wsimod/nodes/demand.py +++ b/wsimod/nodes/demand.py @@ -5,6 +5,7 @@ Converted to totals BD 2022-05-03 """ + from typing import Any, Dict from wsimod.core import constants diff --git a/wsimod/nodes/land.py b/wsimod/nodes/land.py index a97c9f31..d23ad9a6 100644 --- a/wsimod/nodes/land.py +++ b/wsimod/nodes/land.py @@ -3,6 +3,7 @@ @author: Barney """ + import sys from bisect import bisect_left from math import exp, log, log10, sin @@ -633,10 +634,8 @@ def apply_overrides(self, overrides=Dict[str, Any]): self.et0_to_e = overrides.pop("et0_to_e", self.et0_to_e) if "depth" in overrides.keys(): overrides.pop("depth") - print( - "ERROR: specifying depth is depreciated in overrides for \ - impervious surface, please specify pore_depth instead" - ) + print("ERROR: specifying depth is depreciated in overrides for \ + impervious surface, please specify pore_depth instead") self.pore_depth = overrides.pop("pore_depth", self.pore_depth) self.depth = self.pore_depth self.capacity = self.area * self.depth @@ -1411,10 +1410,8 @@ def apply_overrides(self, overrides=Dict[str, Any]): if "depth" in overrides.keys(): overrides.pop("depth") - print( - "ERROR: specifying depth is depreciated in overrides for \ - GrowingSurface, please specify rooting_depth instead" - ) + print("ERROR: specifying depth is depreciated in overrides for \ + GrowingSurface, please specify rooting_depth instead") self.rooting_depth = overrides.pop("rooting_depth", self.rooting_depth) overrides["depth"] = self.rooting_depth super().apply_overrides(overrides) diff --git a/wsimod/nodes/nodes.py b/wsimod/nodes/nodes.py index b3d8af2d..28eca1a0 100644 --- a/wsimod/nodes/nodes.py +++ b/wsimod/nodes/nodes.py @@ -5,6 +5,7 @@ Converted to totals on Thur Apr 21 2022 """ + import logging from typing import Any, Dict diff --git a/wsimod/nodes/nutrient_pool.py b/wsimod/nodes/nutrient_pool.py index ce4b9eac..934b198b 100644 --- a/wsimod/nodes/nutrient_pool.py +++ b/wsimod/nodes/nutrient_pool.py @@ -3,6 +3,7 @@ @author: barna """ + from typing import Any, Dict from wsimod.core import constants diff --git a/wsimod/nodes/sewer.py b/wsimod/nodes/sewer.py index b49546be..8e0b0b48 100644 --- a/wsimod/nodes/sewer.py +++ b/wsimod/nodes/sewer.py @@ -4,6 +4,7 @@ @author: bdobson Converted to totals on 2022-05-03 """ + from typing import Any, Dict from wsimod.core import constants @@ -135,10 +136,8 @@ def apply_overrides(self, overrides: Dict[str, Any] = {}): if "pipe_timearea" in overrides.keys(): pipe_timearea_sum = sum([v for k, v in overrides["pipe_timearea"].items()]) if pipe_timearea_sum != 1: - print( - "ERROR: the sum of pipe_timearea in the overrides dict \ - is not equal to 1, please check it" - ) + print("ERROR: the sum of pipe_timearea in the overrides dict \ + is not equal to 1, please check it") self.pipe_timearea = overrides.pop("pipe_timearea", self.pipe_timearea) super().apply_overrides(overrides) diff --git a/wsimod/nodes/storage.py b/wsimod/nodes/storage.py index 663ee865..e3c68e99 100644 --- a/wsimod/nodes/storage.py +++ b/wsimod/nodes/storage.py @@ -3,6 +3,7 @@ @author: bdobson Converted to totals on 2022-05-03 """ + import warnings from math import exp from typing import Any, Dict @@ -644,16 +645,12 @@ def apply_overrides(self, overrides=Dict[str, Any]): setattr(self, param, overrides.pop(param)) if "area" in overrides.keys(): - warnings.warn( - "WARNING: specifying area is depreciated in overrides \ - for river, please specify length and width instead" - ) + warnings.warn("WARNING: specifying area is depreciated in overrides \ + for river, please specify length and width instead") overrides["area"] = self.length * self.width if "capacity" in overrides.keys(): - warnings.warn( - "ERROR: specifying capacity is depreciated in overrides \ - for river, it is always set as unbounded capacity" - ) + warnings.warn("ERROR: specifying capacity is depreciated in overrides \ + for river, it is always set as unbounded capacity") overrides["capacity"] = constants.UNBOUNDED_CAPACITY super().apply_overrides(overrides) diff --git a/wsimod/nodes/waste.py b/wsimod/nodes/waste.py index 5f381d63..a0fc38d5 100644 --- a/wsimod/nodes/waste.py +++ b/wsimod/nodes/waste.py @@ -3,6 +3,7 @@ @author: bdobson """ + from wsimod.nodes.nodes import Node diff --git a/wsimod/nodes/wtw.py b/wsimod/nodes/wtw.py index 4a957c2a..34dfba7c 100644 --- a/wsimod/nodes/wtw.py +++ b/wsimod/nodes/wtw.py @@ -4,6 +4,7 @@ @author: bdobson Converted to totals on 2022-05-03 """ + from typing import Any, Dict from wsimod.core import constants diff --git a/wsimod/orchestration/model.py b/wsimod/orchestration/model.py index f4aefd87..0dc18f6e 100644 --- a/wsimod/orchestration/model.py +++ b/wsimod/orchestration/model.py @@ -3,6 +3,7 @@ @author: bdobson """ + import csv import gzip import importlib.util