diff --git a/docs/reference-defs.md b/docs/reference-defs.md index 2a1b560c..e673f110 100644 --- a/docs/reference-defs.md +++ b/docs/reference-defs.md @@ -4,7 +4,7 @@ ```yml {% - include-markdown "../swmmanywhere/defs/demo_config.yml" + include-markdown "../src/swmmanywhere/defs/demo_config.yml" comments=false %} ``` @@ -13,7 +13,7 @@ ```yml {% - include-markdown "../swmmanywhere/defs/schema.yml" + include-markdown "../src/swmmanywhere/defs/schema.yml" comments=false %} ``` diff --git a/pyproject.toml b/pyproject.toml index 6b8d7712..7b7acd2c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,7 @@ requires = [ name = "swmmanywhere" description = "SWMManywhere software" readme = "README.md" +license-files = { paths = ["LICENSE", "src/netcomp/LICENSE.txt"] } authors = [ { name = "Barnaby Dobson", email = "b.dobson@imperial.ac.uk" }, { name = "Imperial College London RSE Team", email = "ict-rse-team@imperial.ac.uk" } @@ -17,7 +18,7 @@ requires-python = ">=3.10" classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Science/Research", - "License :: OSI Approved :: MIT License", + "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", @@ -85,10 +86,10 @@ Issues = "https://github.com/ImperialCollegeLondon/SWMManywhere/issues" Source = "https://github.com/ImperialCollegeLondon/SWMManywhere" [tool.hatch.build.targets.sdist] -only-include = ["swmmanywhere", "netcomp"] +packages = [ "src" ] [tool.hatch.build.targets.wheel] -only-include = ["swmmanywhere", "netcomp"] +packages = [ "src" ] [tool.hatch.version] source = "vcs" @@ -101,24 +102,49 @@ select = ["D", "E", "F", "I"] # pydocstyle, pycodestyle, Pyflakes, isort [tool.ruff.lint.per-file-ignores] "tests/*" = ["D100", "D104"] -"netcomp/*" = ["D", "F"] # Ignore all checks for netcomp +"src/netcomp/*" = ["D", "F"] # Ignore all checks for netcomp [tool.ruff.lint.pydocstyle] convention = "google" [tool.ruff.lint.isort] required-imports = ["from __future__ import annotations"] +known-first-party = ["swmmanywhere", "netcomp"] [tool.codespell] -skip = "swmmanywhere/defs/iso_converter.yml,*.inp" +skip = "src/swmmanywhere/defs/iso_converter.yml,*.inp" ignore-words-list = "gage,gages" [tool.pytest.ini_options] -addopts = "-v --import-mode=importlib --cov=swmmanywhere --cov-report=html --doctest-modules --ignore=swmmanywhere/logging.py" +addopts = "-v --cov=src/swmmanywhere --cov-report=html --doctest-modules --ignore=src/swmmanywhere/logging.py" markers = [ "downloads: mark a test as requiring downloads", ] +[tool.coverage.report] +exclude_lines = [ + "if TYPE_CHECKING:", +] +omit = [ + "**/__init__.py", +] +ignore_errors = true + +[tool.coverage.paths] +source = [ "src", "*/site-packages" ] +omit = [ + "**/__init__.py", +] + +[tool.coverage.run] +branch = true +source = [ + "swmmanywhere", +] +omit = [ + "**/__init__.py", +] + [tool.mypy] disallow_any_explicit = false disallow_any_generics = false diff --git a/netcomp/LICENSE.txt b/src/netcomp/LICENSE.txt similarity index 100% rename from netcomp/LICENSE.txt rename to src/netcomp/LICENSE.txt diff --git a/netcomp/README.md b/src/netcomp/README.md similarity index 100% rename from netcomp/README.md rename to src/netcomp/README.md diff --git a/netcomp/__init__.py b/src/netcomp/__init__.py similarity index 100% rename from netcomp/__init__.py rename to src/netcomp/__init__.py diff --git a/netcomp/distance/__init__.py b/src/netcomp/distance/__init__.py similarity index 100% rename from netcomp/distance/__init__.py rename to src/netcomp/distance/__init__.py diff --git a/netcomp/distance/exact.py b/src/netcomp/distance/exact.py similarity index 100% rename from netcomp/distance/exact.py rename to src/netcomp/distance/exact.py diff --git a/netcomp/distance/features.py b/src/netcomp/distance/features.py similarity index 100% rename from netcomp/distance/features.py rename to src/netcomp/distance/features.py diff --git a/netcomp/exception.py b/src/netcomp/exception.py similarity index 100% rename from netcomp/exception.py rename to src/netcomp/exception.py diff --git a/netcomp/linalg/__init__.py b/src/netcomp/linalg/__init__.py similarity index 100% rename from netcomp/linalg/__init__.py rename to src/netcomp/linalg/__init__.py diff --git a/netcomp/linalg/eigenstuff.py b/src/netcomp/linalg/eigenstuff.py similarity index 100% rename from netcomp/linalg/eigenstuff.py rename to src/netcomp/linalg/eigenstuff.py diff --git a/netcomp/linalg/fast_bp.py b/src/netcomp/linalg/fast_bp.py similarity index 100% rename from netcomp/linalg/fast_bp.py rename to src/netcomp/linalg/fast_bp.py diff --git a/netcomp/linalg/matrices.py b/src/netcomp/linalg/matrices.py similarity index 100% rename from netcomp/linalg/matrices.py rename to src/netcomp/linalg/matrices.py diff --git a/netcomp/linalg/resistance.py b/src/netcomp/linalg/resistance.py similarity index 100% rename from netcomp/linalg/resistance.py rename to src/netcomp/linalg/resistance.py diff --git a/swmmanywhere/__init__.py b/src/swmmanywhere/__init__.py similarity index 100% rename from swmmanywhere/__init__.py rename to src/swmmanywhere/__init__.py diff --git a/swmmanywhere/__main__.py b/src/swmmanywhere/__main__.py similarity index 100% rename from swmmanywhere/__main__.py rename to src/swmmanywhere/__main__.py diff --git a/swmmanywhere/defs/basic_drainage_all_bits.inp b/src/swmmanywhere/defs/basic_drainage_all_bits.inp similarity index 100% rename from swmmanywhere/defs/basic_drainage_all_bits.inp rename to src/swmmanywhere/defs/basic_drainage_all_bits.inp diff --git a/swmmanywhere/defs/demo_config.yml b/src/swmmanywhere/defs/demo_config.yml similarity index 100% rename from swmmanywhere/defs/demo_config.yml rename to src/swmmanywhere/defs/demo_config.yml diff --git a/swmmanywhere/defs/iso_converter.yml b/src/swmmanywhere/defs/iso_converter.yml similarity index 100% rename from swmmanywhere/defs/iso_converter.yml rename to src/swmmanywhere/defs/iso_converter.yml diff --git a/swmmanywhere/defs/schema.yml b/src/swmmanywhere/defs/schema.yml similarity index 100% rename from swmmanywhere/defs/schema.yml rename to src/swmmanywhere/defs/schema.yml diff --git a/swmmanywhere/defs/storm.dat b/src/swmmanywhere/defs/storm.dat similarity index 100% rename from swmmanywhere/defs/storm.dat rename to src/swmmanywhere/defs/storm.dat diff --git a/swmmanywhere/defs/swmm_conversion.yml b/src/swmmanywhere/defs/swmm_conversion.yml similarity index 100% rename from swmmanywhere/defs/swmm_conversion.yml rename to src/swmmanywhere/defs/swmm_conversion.yml diff --git a/swmmanywhere/examples/data.py b/src/swmmanywhere/examples/data.py similarity index 100% rename from swmmanywhere/examples/data.py rename to src/swmmanywhere/examples/data.py diff --git a/swmmanywhere/examples/demo_graph.json b/src/swmmanywhere/examples/demo_graph.json similarity index 100% rename from swmmanywhere/examples/demo_graph.json rename to src/swmmanywhere/examples/demo_graph.json diff --git a/swmmanywhere/filepaths.py b/src/swmmanywhere/filepaths.py similarity index 100% rename from swmmanywhere/filepaths.py rename to src/swmmanywhere/filepaths.py diff --git a/swmmanywhere/geospatial_utilities.py b/src/swmmanywhere/geospatial_utilities.py similarity index 100% rename from swmmanywhere/geospatial_utilities.py rename to src/swmmanywhere/geospatial_utilities.py diff --git a/swmmanywhere/graph_utilities.py b/src/swmmanywhere/graph_utilities.py similarity index 100% rename from swmmanywhere/graph_utilities.py rename to src/swmmanywhere/graph_utilities.py diff --git a/swmmanywhere/graphfcns/__init__.py b/src/swmmanywhere/graphfcns/__init__.py similarity index 100% rename from swmmanywhere/graphfcns/__init__.py rename to src/swmmanywhere/graphfcns/__init__.py diff --git a/swmmanywhere/graphfcns/design_graphfcns.py b/src/swmmanywhere/graphfcns/design_graphfcns.py similarity index 100% rename from swmmanywhere/graphfcns/design_graphfcns.py rename to src/swmmanywhere/graphfcns/design_graphfcns.py diff --git a/swmmanywhere/graphfcns/network_cleaning_graphfcns.py b/src/swmmanywhere/graphfcns/network_cleaning_graphfcns.py similarity index 100% rename from swmmanywhere/graphfcns/network_cleaning_graphfcns.py rename to src/swmmanywhere/graphfcns/network_cleaning_graphfcns.py diff --git a/swmmanywhere/graphfcns/outfall_graphfcns.py b/src/swmmanywhere/graphfcns/outfall_graphfcns.py similarity index 100% rename from swmmanywhere/graphfcns/outfall_graphfcns.py rename to src/swmmanywhere/graphfcns/outfall_graphfcns.py diff --git a/swmmanywhere/graphfcns/subcatchment_graphfcns.py b/src/swmmanywhere/graphfcns/subcatchment_graphfcns.py similarity index 100% rename from swmmanywhere/graphfcns/subcatchment_graphfcns.py rename to src/swmmanywhere/graphfcns/subcatchment_graphfcns.py diff --git a/swmmanywhere/graphfcns/topology_graphfcns.py b/src/swmmanywhere/graphfcns/topology_graphfcns.py similarity index 100% rename from swmmanywhere/graphfcns/topology_graphfcns.py rename to src/swmmanywhere/graphfcns/topology_graphfcns.py diff --git a/swmmanywhere/logging.py b/src/swmmanywhere/logging.py similarity index 100% rename from swmmanywhere/logging.py rename to src/swmmanywhere/logging.py diff --git a/swmmanywhere/metric_utilities.py b/src/swmmanywhere/metric_utilities.py similarity index 100% rename from swmmanywhere/metric_utilities.py rename to src/swmmanywhere/metric_utilities.py diff --git a/swmmanywhere/misc/debug_derive_rc.py b/src/swmmanywhere/misc/debug_derive_rc.py similarity index 100% rename from swmmanywhere/misc/debug_derive_rc.py rename to src/swmmanywhere/misc/debug_derive_rc.py diff --git a/swmmanywhere/misc/debug_metrics.py b/src/swmmanywhere/misc/debug_metrics.py similarity index 100% rename from swmmanywhere/misc/debug_metrics.py rename to src/swmmanywhere/misc/debug_metrics.py diff --git a/swmmanywhere/misc/debug_topology.py b/src/swmmanywhere/misc/debug_topology.py similarity index 100% rename from swmmanywhere/misc/debug_topology.py rename to src/swmmanywhere/misc/debug_topology.py diff --git a/swmmanywhere/parameters.py b/src/swmmanywhere/parameters.py similarity index 100% rename from swmmanywhere/parameters.py rename to src/swmmanywhere/parameters.py diff --git a/swmmanywhere/post_processing.py b/src/swmmanywhere/post_processing.py similarity index 100% rename from swmmanywhere/post_processing.py rename to src/swmmanywhere/post_processing.py diff --git a/swmmanywhere/prepare_data.py b/src/swmmanywhere/prepare_data.py similarity index 100% rename from swmmanywhere/prepare_data.py rename to src/swmmanywhere/prepare_data.py diff --git a/swmmanywhere/preprocessing.py b/src/swmmanywhere/preprocessing.py similarity index 100% rename from swmmanywhere/preprocessing.py rename to src/swmmanywhere/preprocessing.py diff --git a/swmmanywhere/shortest_path_utils.py b/src/swmmanywhere/shortest_path_utils.py similarity index 100% rename from swmmanywhere/shortest_path_utils.py rename to src/swmmanywhere/shortest_path_utils.py diff --git a/swmmanywhere/swmmanywhere.py b/src/swmmanywhere/swmmanywhere.py similarity index 100% rename from swmmanywhere/swmmanywhere.py rename to src/swmmanywhere/swmmanywhere.py diff --git a/swmmanywhere/utilities.py b/src/swmmanywhere/utilities.py similarity index 100% rename from swmmanywhere/utilities.py rename to src/swmmanywhere/utilities.py diff --git a/tests/test_post_processing.py b/tests/test_post_processing.py index 864dce19..a49bd0b9 100644 --- a/tests/test_post_processing.py +++ b/tests/test_post_processing.py @@ -16,6 +16,7 @@ fid = ( Path(__file__).parent.parent + / "src" / "swmmanywhere" / "defs" / "basic_drainage_all_bits.inp" @@ -185,6 +186,7 @@ def test_synthetic_write(): comparison_file = addresses.model_paths.model / "model_base.inp" template_fid = ( Path(__file__).parent.parent + / "src" / "swmmanywhere" / "defs" / "basic_drainage_all_bits.inp" @@ -234,7 +236,9 @@ def test_format_to_swmm_dict(): data_dict = generate_data_dict() data_dict = stt.format_to_swmm_dict(**data_dict) - rain_fid = Path(__file__).parent.parent / "swmmanywhere" / "defs" / "storm.dat" + rain_fid = ( + Path(__file__).parent.parent / "src" / "swmmanywhere" / "defs" / "storm.dat" + ) with tempfile.TemporaryDirectory() as temp_dir: temp_dir = Path(temp_dir) shutil.copy(rain_fid, temp_dir / "storm.dat") diff --git a/tests/test_swmmanywhere.py b/tests/test_swmmanywhere.py index 84afc800..34617aaa 100644 --- a/tests/test_swmmanywhere.py +++ b/tests/test_swmmanywhere.py @@ -1,4 +1,5 @@ """Tests for the main module.""" + from __future__ import annotations import os @@ -16,7 +17,7 @@ def test_run(): """Test the run function.""" - demo_dir = Path(__file__).parent.parent / "swmmanywhere" / "defs" + demo_dir = Path(__file__).parent.parent / "src" / "swmmanywhere" / "defs" model = demo_dir / "basic_drainage_all_bits.inp" storevars = ["flooding", "flow", "runoff", "depth"] results = swmmanywhere.run(model, reporting_iters=50, storevars=storevars) @@ -39,7 +40,7 @@ def test_swmmanywhere(): with tempfile.TemporaryDirectory() as temp_dir: # Load the config test_data_dir = Path(__file__).parent / "test_data" - defs_dir = Path(__file__).parent.parent / "swmmanywhere" / "defs" + defs_dir = Path(__file__).parent.parent / "src" / "swmmanywhere" / "defs" with (defs_dir / "demo_config.yml").open("r") as f: config = yaml.safe_load(f) @@ -97,7 +98,7 @@ def test_swmmanywhere(): def test_load_config_file_validation(): """Test the file validation of the config.""" with tempfile.TemporaryDirectory() as temp_dir: - defs_dir = Path(__file__).parent.parent / "swmmanywhere" / "defs" + defs_dir = Path(__file__).parent.parent / "src" / "swmmanywhere" / "defs" base_dir = Path(temp_dir) # Test file not found @@ -124,7 +125,7 @@ def test_load_config_file_validation(): def test_load_config_schema_validation(): """Test the schema validation of the config.""" with tempfile.TemporaryDirectory() as temp_dir: - defs_dir = Path(__file__).parent.parent / "swmmanywhere" / "defs" + defs_dir = Path(__file__).parent.parent / "src" / "swmmanywhere" / "defs" base_dir = Path(temp_dir) # Load the config @@ -147,7 +148,7 @@ def test_save_config(): """Test the save_config function.""" with tempfile.TemporaryDirectory() as temp_dir: temp_dir = Path(temp_dir) - defs_dir = Path(__file__).parent.parent / "swmmanywhere" / "defs" + defs_dir = Path(__file__).parent.parent / "src" / "swmmanywhere" / "defs" with (defs_dir / "demo_config.yml").open("r") as f: config = yaml.safe_load(f)