hydamo-validation 1.3.0b4__tar.gz → 1.3.1b1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of hydamo-validation might be problematic. Click here for more details.

Files changed (50) hide show
  1. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/PKG-INFO +1 -1
  2. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/__init__.py +1 -1
  3. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/logical_validation.py +7 -6
  4. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/summaries.py +1 -0
  5. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/syntax_validation.py +9 -1
  6. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/validator.py +1 -3
  7. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation.egg-info/PKG-INFO +1 -1
  8. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation.egg-info/SOURCES.txt +1 -0
  9. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/pyproject.toml +46 -46
  10. hydamo_validation-1.3.1b1/tests/test_dommelerwaard.py +87 -0
  11. hydamo_validation-1.3.1b1/tests/test_testset.py +43 -0
  12. hydamo_validation-1.3.0b4/tests/test_dommelerwaard.py +0 -31
  13. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/LICENSE +0 -0
  14. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/README.md +0 -0
  15. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/datamodel.py +0 -0
  16. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/datasets.py +0 -0
  17. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/functions/__init__.py +0 -0
  18. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/functions/general.py +0 -0
  19. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/functions/logic.py +0 -0
  20. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/functions/topologic.py +0 -0
  21. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/geometry.py +0 -0
  22. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/schemas/hydamo/HyDAMO_2.2.json +0 -0
  23. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/schemas/hydamo/HyDAMO_2.3.json +0 -0
  24. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/schemas/rules/rules_1.0.json +0 -0
  25. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/schemas/rules/rules_1.1.json +0 -0
  26. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/schemas/rules/rules_1.2.json +0 -0
  27. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/schemas/rules/rules_1.3.json +0 -0
  28. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/styles/hydroobject.qml +0 -0
  29. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/styles/hydroobject.sld +0 -0
  30. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/styles.py +0 -0
  31. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation/utils.py +0 -0
  32. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation.egg-info/dependency_links.txt +0 -0
  33. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation.egg-info/requires.txt +0 -0
  34. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation.egg-info/top_level.txt +0 -0
  35. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/hydamo_validation.egg-info/zip-safe +0 -0
  36. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/setup.cfg +0 -0
  37. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/setup.py +0 -0
  38. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/tests/test_datasets.py +0 -0
  39. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/tests/test_general_functions.py +0 -0
  40. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/tests/test_hydamo_2_2.py +0 -0
  41. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/tests/test_init.py +0 -0
  42. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/tests/test_logic_functions.py +0 -0
  43. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/tests/test_not_overlapping.py +0 -0
  44. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/tests/test_productie.py +0 -0
  45. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/tests/test_structures_at_interersections.py +0 -0
  46. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/tests/test_summaries.py +0 -0
  47. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/tests/test_topologic_functions.py +0 -0
  48. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/tests/test_validationrules.py +0 -0
  49. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/tests/test_wrij.py +0 -0
  50. {hydamo_validation-1.3.0b4 → hydamo_validation-1.3.1b1}/tests/test_wrij_profielen.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hydamo_validation
3
- Version: 1.3.0b4
3
+ Version: 1.3.1b1
4
4
  Summary: Validation module for HyDAMO data
5
5
  Author-email: Daniel Tollenaar <daniel@d2hydro.nl>
6
6
  License: MIT
@@ -1,7 +1,7 @@
1
1
  __author__ = ["Het Waterschapshuis", "D2HYDRO", "HKV", "HydroConsult"]
2
2
  __copyright__ = "Copyright 2021, HyDAMO ValidatieTool"
3
3
  __credits__ = ["D2HYDRO", "HKV", "HydroConsult"]
4
- __version__ = "1.3.0b4"
4
+ __version__ = "1.3.1b1"
5
5
 
6
6
  __license__ = "MIT"
7
7
  __maintainer__ = "Daniel Tollenaar"
@@ -1,5 +1,6 @@
1
1
  """Logical validation."""
2
2
 
3
+ # %%
3
4
  from hydamo_validation import general_functions, logic_functions, topologic_functions
4
5
  from shapely.geometry import LineString, Point, Polygon
5
6
  import numpy as np
@@ -102,9 +103,9 @@ def gdf_add_summary(
102
103
  if critical:
103
104
  gdf.loc[gdf[variable] == False, "invalid_critical"] += f"{rule_id}{separator}"
104
105
  else:
105
- gdf.loc[
106
- gdf[variable] == False, "invalid_non_critical"
107
- ] += f"{rule_id}{separator}"
106
+ gdf.loc[gdf[variable] == False, "invalid_non_critical"] += (
107
+ f"{rule_id}{separator}"
108
+ )
108
109
  if tags is not None:
109
110
  gdf.loc[tags_indices, ("tags_assigned")] += f"{tags}{separator}"
110
111
  gdf.loc[gdf[variable] == False, "tags_invalid"] += f"{tags}{separator}"
@@ -122,13 +123,13 @@ def execute(
122
123
  ):
123
124
  """Execute the logical validation."""
124
125
 
125
- object_rules_sets = (
126
+ object_rules_sets = [
126
127
  i
127
128
  for i in validation_rules_sets["objects"]
128
129
  if i["object"] in datamodel.data_layers
129
- )
130
+ ]
130
131
  logger.info(
131
- rf"lagen met valide objecten én regels: {[i["object"] for i in object_rules_sets]}"
132
+ rf"lagen met valide objecten en regels: {[i["object"] for i in object_rules_sets]}"
132
133
  )
133
134
  for object_rules in object_rules_sets:
134
135
  col_translation: dict = {}
@@ -161,6 +161,7 @@ class LayersSummary:
161
161
  layer=object_layer,
162
162
  driver="GPKG",
163
163
  engine="pyogrio",
164
+ layer_options={"OVERWRITE": "YES"},
164
165
  )
165
166
  layers += [object_layer]
166
167
  else:
@@ -249,13 +249,21 @@ def fields_syntax(gdf, schema, validation_schema, keep_columns=[]):
249
249
  geotype = next(
250
250
  (i["dtype"] for i in validation_schema if i["id"] == "geometry"), None
251
251
  )
252
+
253
+ # since shapely2.0 we can't use PointZ anymore
252
254
  if geotype:
255
+ has_z = any(i.endswith("Z") for i in geotype)
256
+ if has_z:
257
+ geotype = [i[:-1] if i.endswith("Z") else i for i in geotype]
253
258
  result_col = "syntax_geometry"
254
259
  validation_gdf[result_col] = ""
255
260
 
256
261
  bool_series = ~(
257
- ~result_gdf["geometry"].is_valid | result_gdf["geometry"].type.isin(geotype)
262
+ result_gdf["geometry"].is_valid
263
+ & result_gdf["geometry"].geom_type.isin(geotype)
264
+ & (result_gdf["geometry"].has_z == has_z)
258
265
  )
266
+
259
267
  validation_gdf.loc[bool_series, result_col] = result_gdf[
260
268
  bool_series
261
269
  ].geometry.apply(lambda x: f"{x.type} -> NULL (7)")
@@ -281,9 +281,7 @@ def _validator(
281
281
  gdf, schema = datasets.read_layer(
282
282
  layer, result_summary=result_summary, status_object=status_object
283
283
  )
284
- if (
285
- gdf.empty
286
- ): # pass if gdf is empty. Most likely due to mall-formed or ill-specifiec status_object
284
+ if gdf.empty: # pass if gdf is empty. Most likely due to mall-formed or ill-specifiec status_object
287
285
  logger.warning(
288
286
  f"{layer}: geen objecten ingelezen. Zorg dat alle waarden in de kolom 'status_object' voorkomen in {status_object}"
289
287
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hydamo_validation
3
- Version: 1.3.0b4
3
+ Version: 1.3.1b1
4
4
  Summary: Validation module for HyDAMO data
5
5
  Author-email: Daniel Tollenaar <daniel@d2hydro.nl>
6
6
  License: MIT
@@ -40,6 +40,7 @@ tests/test_not_overlapping.py
40
40
  tests/test_productie.py
41
41
  tests/test_structures_at_interersections.py
42
42
  tests/test_summaries.py
43
+ tests/test_testset.py
43
44
  tests/test_topologic_functions.py
44
45
  tests/test_validationrules.py
45
46
  tests/test_wrij.py
@@ -1,46 +1,46 @@
1
- [build-system]
2
- requires = ["setuptools>=61"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "hydamo_validation"
7
- description = "Validation module for HyDAMO data"
8
- readme = "README.md"
9
- authors = [
10
- { name = "Daniel Tollenaar", email = "daniel@d2hydro.nl" },
11
- ]
12
- license = { text = "MIT" }
13
-
14
- requires-python = ">=3.12"
15
- dependencies = [
16
- "geopandas",
17
- "pandas>=2",
18
- "pyogrio",
19
- "rasterio",
20
- "shapely>=2",
21
- "rasterstats",
22
- ]
23
-
24
- dynamic = ["version"]
25
-
26
- [project.optional-dependencies]
27
- tests = ["pytest"]
28
-
29
- [tool.flake8]
30
- max-line-length = 120
31
- max-complexity = 10
32
-
33
- [tool.setuptools]
34
- zip-safe = true
35
-
36
- [tool.setuptools.dynamic]
37
- version = { attr = "hydamo_validation.__version__" }
38
-
39
- [tool.setuptools.packages.find]
40
- include = ["hydamo_validation", "hydamo_validation.*"]
41
-
42
- [tool.setuptools.package-data]
43
- hydamo_validation = ["schemas/hydamo/*.json","schemas/rules/*.json", "styles/*.*"]
44
-
45
- [project.urls]
46
- Source = "https://github.com/HetWaterschapshuis/HyDAMOValidatieModule"
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "hydamo_validation"
7
+ description = "Validation module for HyDAMO data"
8
+ readme = "README.md"
9
+ authors = [
10
+ { name = "Daniel Tollenaar", email = "daniel@d2hydro.nl" },
11
+ ]
12
+ license = { text = "MIT" }
13
+
14
+ requires-python = ">=3.12"
15
+ dependencies = [
16
+ "geopandas",
17
+ "pandas>=2",
18
+ "pyogrio",
19
+ "rasterio",
20
+ "shapely>=2",
21
+ "rasterstats",
22
+ ]
23
+
24
+ dynamic = ["version"]
25
+
26
+ [project.optional-dependencies]
27
+ tests = ["pytest"]
28
+
29
+ [tool.flake8]
30
+ max-line-length = 120
31
+ max-complexity = 10
32
+
33
+ [tool.setuptools]
34
+ zip-safe = true
35
+
36
+ [tool.setuptools.dynamic]
37
+ version = { attr = "hydamo_validation.__version__" }
38
+
39
+ [tool.setuptools.packages.find]
40
+ include = ["hydamo_validation", "hydamo_validation.*"]
41
+
42
+ [tool.setuptools.package-data]
43
+ hydamo_validation = ["schemas/hydamo/*.json","schemas/rules/*.json", "styles/*.*"]
44
+
45
+ [project.urls]
46
+ Source = "https://github.com/HetWaterschapshuis/HyDAMOValidatieModule"
@@ -0,0 +1,87 @@
1
+ # %%
2
+ from hydamo_validation import validator
3
+ from pathlib import Path
4
+ import pandas as pd
5
+
6
+ DATA_DIR = Path(r"d:\repositories\HyDAMOValidatieModule\tests\data")
7
+ coverage = {"AHN": DATA_DIR.joinpath(r"dtm")}
8
+ directory = DATA_DIR.joinpath(r"tasks/test_dommelerwaard")
9
+ exports_dir = Path(__file__).parent / "exports"
10
+ exports_dir.mkdir(exist_ok=True)
11
+
12
+ hydamo_validator = validator(
13
+ output_types=["geopackage", "csv", "geojson"], coverages=coverage, log_level="INFO"
14
+ )
15
+
16
+
17
+ datamodel, layer_summary, result_summary = hydamo_validator(
18
+ directory=directory, raise_error=False
19
+ )
20
+
21
+
22
+ def test_hydroobjects():
23
+ EXPECTED_INDEX = pd.Index(
24
+ [
25
+ "nen3610id",
26
+ "code",
27
+ "geometry",
28
+ "syntax_breedte",
29
+ "syntax_categorieoppwaterlichaam",
30
+ "syntax_code",
31
+ "syntax_created_date",
32
+ "syntax_detailniveaugeometrie",
33
+ "syntax_draineert",
34
+ "syntax_featuretype",
35
+ "syntax_getijdebeinvloed",
36
+ "syntax_globalid",
37
+ "syntax_hydroobjectgroeperingid",
38
+ "syntax_hyperlink",
39
+ "syntax_krwstromendid",
40
+ "syntax_last_edited_date",
41
+ "syntax_lengte",
42
+ "syntax_lvpublicatiedatum",
43
+ "syntax_metadataid",
44
+ "syntax_naam",
45
+ "syntax_namespace",
46
+ "syntax_nen3610id",
47
+ "syntax_niveau",
48
+ "syntax_objectid",
49
+ "syntax_ontstaanswijze",
50
+ "syntax_opmerking",
51
+ "syntax_oppervlaktewaterlichaamid",
52
+ "syntax_oppwatervolgnummer",
53
+ "syntax_persistentie",
54
+ "syntax_ruimtelijkeafbakeningbekend",
55
+ "syntax_ruwheidhoog",
56
+ "syntax_ruwheidlaag",
57
+ "syntax_soortoppwaterkwaliteit",
58
+ "syntax_soortoppwaterkwantiteit",
59
+ "syntax_statusleggerwatersysteem",
60
+ "syntax_statusobject",
61
+ "syntax_typeruwheid",
62
+ "syntax_vaarwegid",
63
+ "syntax_geometry",
64
+ "syntax_oordeel",
65
+ "validate_000_lengte_gt_1m",
66
+ "validate_001_goed_gesplitst",
67
+ "validate_002_goede_kruising",
68
+ "validate_003_geen_eindpunt",
69
+ "validate_006_kunstwerk_op_peilscheiding",
70
+ "validate_005_kunstwerk_tussen_hobject",
71
+ "rating",
72
+ "valid",
73
+ "invalid",
74
+ "invalid_critical",
75
+ "invalid_non_critical",
76
+ "ignored",
77
+ "summary",
78
+ "tags_assigned",
79
+ "tags_invalid",
80
+ "date_check",
81
+ ]
82
+ )
83
+
84
+ assert layer_summary.hydroobject.columns.equals(EXPECTED_INDEX)
85
+
86
+
87
+ # %%
@@ -0,0 +1,43 @@
1
+ from pathlib import Path
2
+ from hydamo_validation import validator
3
+ import pandas as pd
4
+ import pytest
5
+ import shutil
6
+
7
+ DATA_DIR = Path(__file__).parent.joinpath("data")
8
+ COVERAGE = {"AHN": DATA_DIR.joinpath(r"dtm")}
9
+ DIRECTORY = DATA_DIR.joinpath("tasks", "test_testset")
10
+
11
+ hydamo_validator = validator(
12
+ output_types=["geopackage"], coverages=COVERAGE, log_level="INFO"
13
+ )
14
+
15
+
16
+ @pytest.fixture
17
+ def result():
18
+ results_dir = DIRECTORY / "results"
19
+ if results_dir.exists():
20
+ shutil.rmtree(DIRECTORY / "results")
21
+ return hydamo_validator(directory=DIRECTORY, raise_error=True)
22
+
23
+
24
+ def test_results_available(result):
25
+ # assert if result is generated
26
+ assert result is not None
27
+
28
+
29
+ def test_validate_result(result):
30
+ # unpack result
31
+ datamodel, layer_summary, result_summary = result
32
+
33
+ # check if profielpunt is available
34
+ assert hasattr(layer_summary, "profielpunt")
35
+
36
+ # invalid geometries contain (7) in syntax_geometry column
37
+ result = layer_summary.profielpunt.syntax_geometry.apply(
38
+ lambda x: "(7)" not in x
39
+ ).reset_index(drop=True)
40
+
41
+ # we expecte only the first geometry to be valid, containing PointZ, Point, LineString, LineStringZ
42
+ expected_result = pd.Series([True, False, False, False], name="syntax_geometry")
43
+ assert result.equals(expected_result)
@@ -1,31 +0,0 @@
1
- # %%
2
- from hydamo_validation import validator
3
- from hydamo_validation import __version__
4
- from pathlib import Path
5
- from datetime import datetime
6
-
7
- # try:
8
- # from .config import DATA_DIR
9
- # except ImportError:
10
- # from config import DATA_DIR
11
-
12
- DATA_DIR = Path(r"d:\repositories\HyDAMOValidatieModule\tests\data")
13
- coverage = {"AHN": DATA_DIR.joinpath(r"dtm")}
14
- directory = DATA_DIR.joinpath(r"tasks/test_dommelerwaard")
15
- exports_dir = Path(__file__).parent / "exports"
16
- exports_dir.mkdir(exist_ok=True)
17
-
18
- # hydamo_validator = validator(output_types=["geopackage", "csv", "geojson"],
19
- # coverages=coverage,
20
- # log_level="INFO"
21
- # )
22
-
23
-
24
- # datamodel, layer_summary, result_summary = hydamo_validator(
25
- # directory=directory,
26
- # raise_error=True
27
- # )
28
-
29
- # datamodel.to_geopackage(exports_dir / "datamodel.gpkg",
30
- # use_schema=False)
31
- # %%