Skip to content

Commit 05a4ccb

Browse files
committed
fix: update tests and minor indents
1 parent dc47779 commit 05a4ccb

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

map2loop/data_checks.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -292,19 +292,20 @@ def check_fault_fields_validity(mapdata) -> Tuple[bool, str]:
292292
f"Datatype FAULT: Column '{structtype_column}' contains NaN, empty, or blank values. Processing might not work as expected."
293293
)
294294

295-
# Check if "fault_text" is defined and contained in the column
296-
fault_text = config.get("fault_text", None)
297-
if not fault_text:
298-
logger.error(
299-
"Datatype FAULT: 'fault_text' is not defined in the configuration, but it is required to filter faults."
300-
)
301-
return (True, "Datatype FAULT: 'fault_text' is not defined in the configuration.")
295+
# Check if "fault_text" is defined and contained in the column
296+
fault_text = config.get("fault_text", None)
297+
298+
# Check if the structtype_column exists in the fault_data
299+
if structtype_column not in fault_data.columns:
300+
logger.warning(
301+
f"Datatype FAULT: The column '{structtype_column}' is not present in the fault data."
302+
)
302303

304+
else:
303305
if not fault_data[structtype_column].str.contains(fault_text).any():
304306
logger.error(
305-
f"Datatype FAULT: The 'fault_text' value '{fault_text}' is not found in column '{structtype_column}'. Ensure it is correctly defined at least for one row"
307+
f"Datatype FAULT: The 'fault_text' value '{fault_text}' is not found in column '{structtype_column}'. Project might end up with no faults"
306308
)
307-
return (True, f"Datatype FAULT: The 'fault_text' value '{fault_text}' is not found in column '{structtype_column}'.")
308309

309310
#checks on name column
310311
name_column = config.get("name_column")

map2loop/mapdata.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,6 @@ def parse_fault_map(self) -> tuple:
911911
Returns:
912912
tuple: A tuple of (bool: success/fail, str: failure message)
913913
"""
914-
915914
# Create a new geodataframe
916915
faults = geopandas.GeoDataFrame(self.raw_data[Datatype.FAULT]["geometry"])
917916

@@ -920,6 +919,7 @@ def parse_fault_map(self) -> tuple:
920919

921920
# update minimum fault length either with the value from the config or calculate it
922921
if self.minimum_fault_length < 0:
922+
logger.info("Calculating minimum fault length")
923923
self.minimum_fault_length = calculate_minimum_fault_length(
924924
bbox=self.bounding_box, area_percentage=0.05
925925
)
@@ -928,7 +928,7 @@ def parse_fault_map(self) -> tuple:
928928
# crop
929929
faults = faults.loc[faults.geometry.length >= self.minimum_fault_length]
930930

931-
if config["structtype_column"] in self.raw_data[Datatype.FAULT]:
931+
if config["structtype_column"] in self.raw_data[Datatype.FAULT]:
932932
faults["FEATURE"] = self.raw_data[Datatype.FAULT][config["structtype_column"]]
933933
faults = faults[faults["FEATURE"].astype(str).str.contains(config["fault_text"])]
934934
if self.verbose_level > VerboseLevel.NONE:
@@ -962,6 +962,7 @@ def parse_fault_map(self) -> tuple:
962962
else:
963963
logger.info("None of the fault ignore codes exist in the original fault data.")
964964
pass
965+
965966

966967
# parse dip column
967968
if config["dip_column"] in self.raw_data[Datatype.FAULT]:

tests/mapdata/test_input_data_geology.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import geopandas as gpd
33
import shapely.geometry
44
from map2loop.mapdata import MapData
5+
from map2loop.data_checks import check_geology_fields_validity
56

67
# Datatype Enum
78
class Datatype:
@@ -196,6 +197,6 @@ def test_check_geology_fields_validity(geology_data, expected_validity, expected
196197
map_data.raw_data[Datatype.GEOLOGY] = geology_gdf
197198

198199
# Test the check_geology_fields_validity function
199-
validity_check, message = map_data.check_geology_fields_validity()
200+
validity_check, message = check_geology_fields_validity(map_data)
200201
assert validity_check == expected_validity
201202
assert message == expected_message

tests/mapdata/test_input_data_structure.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import geopandas as gpd
33
import shapely.geometry
44
from map2loop.mapdata import MapData
5+
from map2loop.data_checks import check_structure_fields_validity
56

67
# Datatype Enum
78
class Datatype:
@@ -130,6 +131,6 @@ def test_check_structure_fields_validity(structure_data, expected_validity, expe
130131
map_data.raw_data[Datatype.STRUCTURE] = structure_gdf
131132

132133
# Test the check_structure_fields_validity function
133-
validity_check, message = map_data.check_structure_fields_validity()
134+
validity_check, message = check_structure_fields_validity(map_data)
134135
assert validity_check == expected_validity
135136
assert message == expected_message

0 commit comments

Comments
 (0)