Skip to content

Commit

Permalink
chore: update tests for geometry refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
AngRodrigues committed Jan 13, 2025
1 parent e919f94 commit 0002262
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions map2loop/data_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ def check_keys(d: dict, parent_key=""):
logger.error("minimum_fault_length must be a number.")
raise ValueError(f"minimum_fault_length must be a number, instead got: {type(mfl)}")


@beartype.beartype
def validate_geometry(
geodata: geopandas.GeoDataFrame,
expected_geom_types: List[type],
Expand All @@ -690,7 +690,7 @@ def validate_geometry(
# 1. Check if all geometries are valid
if not geodata.geometry.is_valid.all():
logger.error(f"Invalid geometries found in datatype {datatype_name}. Please fix them before proceeding.")
return True, f"Invalid geometries found in datatype {datatype_name}."
return True, f"Invalid geometries found in datatype {datatype_name}"

# 2. Check if all geometries are of the expected types
if not geodata.geometry.apply(lambda geom: isinstance(geom, tuple(expected_geom_types))).all():
Expand All @@ -707,5 +707,5 @@ def validate_geometry(
)

# If all checks pass
logger.debug(f"Geometry validation passed for datatype {datatype_name}.")
logger.debug(f"Geometry validation passed for datatype {datatype_name}")
return False, ""
2 changes: 1 addition & 1 deletion tests/data_checks/test_input_data_faults.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
{"structtype_column": "FEATURE", "fault_text": "Fault", "objectid_column": "ID"},
True,
"Invalid geometries found in FAULT data."
"Invalid geometries found in datatype FAULT"
),
# Non-string FEATURE column
Expand Down
4 changes: 2 additions & 2 deletions tests/data_checks/test_input_data_fold.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
(
{
"geometry": [
shapely.geometry.Point(0, 0), # Invalid type
shapely.geometry.LineString([(0,0), (0,0)]), # Invalid type
shapely.geometry.LineString([(0, 0), (1, 1)])
],
"FEATURE": ["fold A", "fold B"],
Expand All @@ -36,7 +36,7 @@
},
{"structtype_column": "FEATURE", "fold_text": "fold", "objectid_column": "ID", "description_column": "description"},
True,
"Invalid geometry types found in FOLD data."
"Invalid geometries found in datatype FOLD"
),
# Non-string FEATURE column
(
Expand Down

0 comments on commit 0002262

Please sign in to comment.