From 6b2768126190b2048da340de7c226a9a066916b6 Mon Sep 17 00:00:00 2001 From: Felix Oesterle Date: Fri, 24 Apr 2026 08:54:34 +0200 Subject: [PATCH] chore(data): update `scarpExample` inputs with new points and polygon configurations - Replaced `points_coordinates` files with `EllipsoidMethodPoints_coordinates` and `PlaneMethodPoints_coordinates` equivalents. - Updated `scarpFluchthorn_perimeter` polygon data and added corresponding projection files. chore(tests): fix scarp pytests with new data layout --- .../EllipsoidMethodPoints_coordinates.dbf | Bin 0 -> 427 bytes .../EllipsoidMethodPoints_coordinates.prj | 1 + .../EllipsoidMethodPoints_coordinates.shp | Bin 0 -> 128 bytes .../EllipsoidMethodPoints_coordinates.shx | Bin 0 -> 108 bytes .../Inputs/POINTS/points_coordinates.dbf | Bin 483 -> 0 bytes .../Inputs/POINTS/points_coordinates.shp | Bin 128 -> 0 bytes .../Inputs/POINTS/points_coordinates.shx | Bin 108 -> 0 bytes .../PlaneMethodPoints_coordinates.dbf | Bin 0 -> 164 bytes .../PlaneMethodPoints_coordinates.prj | 1 + .../PlaneMethodPoints_coordinates.shp | Bin 0 -> 128 bytes .../PlaneMethodPoints_coordinates.shx | Bin 0 -> 108 bytes .../POLYGONS/scarpFluchthorn_perimeter.dbf | Bin 77 -> 77 bytes .../POLYGONS/scarpFluchthorn_perimeter.prj | 1 + .../POLYGONS/scarpFluchthorn_perimeter.shp | Bin 236 -> 236 bytes .../POLYGONS/scarpFluchthorn_perimeter.shx | Bin 108 -> 108 bytes avaframe/tests/test_scarp.py | 137 ++++++++---------- 16 files changed, 60 insertions(+), 80 deletions(-) create mode 100644 avaframe/data/scarpExample/Inputs/POINTS/EllipsoidMethodPoints_coordinates.dbf create mode 100644 avaframe/data/scarpExample/Inputs/POINTS/EllipsoidMethodPoints_coordinates.prj create mode 100644 avaframe/data/scarpExample/Inputs/POINTS/EllipsoidMethodPoints_coordinates.shp create mode 100644 avaframe/data/scarpExample/Inputs/POINTS/EllipsoidMethodPoints_coordinates.shx delete mode 100644 avaframe/data/scarpExample/Inputs/POINTS/points_coordinates.dbf delete mode 100644 avaframe/data/scarpExample/Inputs/POINTS/points_coordinates.shp delete mode 100644 avaframe/data/scarpExample/Inputs/POINTS/points_coordinates.shx create mode 100644 avaframe/data/scarpExample/Inputs/POINTS_plane/PlaneMethodPoints_coordinates.dbf create mode 100644 avaframe/data/scarpExample/Inputs/POINTS_plane/PlaneMethodPoints_coordinates.prj create mode 100644 avaframe/data/scarpExample/Inputs/POINTS_plane/PlaneMethodPoints_coordinates.shp create mode 100644 avaframe/data/scarpExample/Inputs/POINTS_plane/PlaneMethodPoints_coordinates.shx create mode 100644 avaframe/data/scarpExample/Inputs/POLYGONS/scarpFluchthorn_perimeter.prj diff --git a/avaframe/data/scarpExample/Inputs/POINTS/EllipsoidMethodPoints_coordinates.dbf b/avaframe/data/scarpExample/Inputs/POINTS/EllipsoidMethodPoints_coordinates.dbf new file mode 100644 index 0000000000000000000000000000000000000000..937a33eac986898334353aadfb53bc1696d7978e GIT binary patch literal 427 zcmZRsV-aU$U|?WmTnQvGL2hD2N@_t#22jQiBrCy>swO3~z%eg9Cl!}`ep*^_Y6(~m zR{h1PxtY0%S@}gc%m>S7=HZkF+MkjM)QrpiqWqFXeD32_00Tn<13d#&0Ff}lA+CT! Q9G7}r;-)yv!8BhA08jZi2><{9 literal 0 HcmV?d00001 diff --git a/avaframe/data/scarpExample/Inputs/POINTS/EllipsoidMethodPoints_coordinates.prj b/avaframe/data/scarpExample/Inputs/POINTS/EllipsoidMethodPoints_coordinates.prj new file mode 100644 index 000000000..f45cbadf0 --- /dev/null +++ b/avaframe/data/scarpExample/Inputs/POINTS/EllipsoidMethodPoints_coordinates.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] \ No newline at end of file diff --git a/avaframe/data/scarpExample/Inputs/POINTS/EllipsoidMethodPoints_coordinates.shp b/avaframe/data/scarpExample/Inputs/POINTS/EllipsoidMethodPoints_coordinates.shp new file mode 100644 index 0000000000000000000000000000000000000000..e1b59674dfb6b691312c56787d446df527849f10 GIT binary patch literal 128 zcmZQzQ0HR64jf)EGcYg$<*w&%-DvUt;DNdC68x|4WOwZF>D@M3+#^A OwWElFjNt+i=z0OkCm6B- literal 0 HcmV?d00001 diff --git a/avaframe/data/scarpExample/Inputs/POINTS/EllipsoidMethodPoints_coordinates.shx b/avaframe/data/scarpExample/Inputs/POINTS/EllipsoidMethodPoints_coordinates.shx new file mode 100644 index 0000000000000000000000000000000000000000..e13af6299bdd3c555a7d5a104eec6a5e4d59627b GIT binary patch literal 108 zcmZQzQ0HR64$NLKGcYg$<*w&%-DvUt;DNdC68x|4WOwZF>D@M3+#^A LwWEj{0eM^iC&&@! literal 0 HcmV?d00001 diff --git a/avaframe/data/scarpExample/Inputs/POINTS/points_coordinates.dbf b/avaframe/data/scarpExample/Inputs/POINTS/points_coordinates.dbf deleted file mode 100644 index b0e1d2757eab9334f2a173df848cde4eb9ab0868..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 483 zcmZRsV-jLyU|>*WJP0H)L2hD2N@_t#22jQiBrCy>swO3~z%eg9Cl!}`ep*^_Y6(~m zR{h1PxtY0%S@}gc%m>S7=HZkF+MkjM)QrpiqWqFXeD13%PEAb#Ysc0L%D4Hvj+t diff --git a/avaframe/data/scarpExample/Inputs/POINTS/points_coordinates.shp b/avaframe/data/scarpExample/Inputs/POINTS/points_coordinates.shp deleted file mode 100644 index a1cb3ab00538d986f34e25b221539ee816a90ae5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 128 ycmZQzQ0HR64jf)EGcYg$<*w&%-DvUt;DNdC68x|4WOqd8W7m!%3NnTZn^^#oupOKL diff --git a/avaframe/data/scarpExample/Inputs/POINTS/points_coordinates.shx b/avaframe/data/scarpExample/Inputs/POINTS/points_coordinates.shx deleted file mode 100644 index 9f4f0f8bf475fc27009a420457875354c455e413..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 108 xcmZQzQ0HR64$NLKGcYg$<*w&%-DvUt;DNdC68x|4WOqd8W7m!%Y6RqQ0RW{J6kGrR diff --git a/avaframe/data/scarpExample/Inputs/POINTS_plane/PlaneMethodPoints_coordinates.dbf b/avaframe/data/scarpExample/Inputs/POINTS_plane/PlaneMethodPoints_coordinates.dbf new file mode 100644 index 0000000000000000000000000000000000000000..0fcf199fafd27bd8c5c6ad827cee37abeed01bd9 GIT binary patch literal 164 zcmZRsV-aIyU|?uuPy&*epsF}EH3cH<2co!{QPrem7NlerfyHpiC+4N+qykl7mFHCe W0wW^>13d!+0}xxm7{N3GGo=7y1P|E& literal 0 HcmV?d00001 diff --git a/avaframe/data/scarpExample/Inputs/POINTS_plane/PlaneMethodPoints_coordinates.prj b/avaframe/data/scarpExample/Inputs/POINTS_plane/PlaneMethodPoints_coordinates.prj new file mode 100644 index 000000000..f45cbadf0 --- /dev/null +++ b/avaframe/data/scarpExample/Inputs/POINTS_plane/PlaneMethodPoints_coordinates.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] \ No newline at end of file diff --git a/avaframe/data/scarpExample/Inputs/POINTS_plane/PlaneMethodPoints_coordinates.shp b/avaframe/data/scarpExample/Inputs/POINTS_plane/PlaneMethodPoints_coordinates.shp new file mode 100644 index 0000000000000000000000000000000000000000..a5689bf1749c8b680654f39f6d439c70d24bdbec GIT binary patch literal 128 zcmZQzQ0HR64jf)EGcYg$<*w&%-DvUt;DNdC68x|4WOoee63b2yI&h%yyLPY7Wp+pG O+EGM7#&CfMbiDw*ix_+W literal 0 HcmV?d00001 diff --git a/avaframe/data/scarpExample/Inputs/POINTS_plane/PlaneMethodPoints_coordinates.shx b/avaframe/data/scarpExample/Inputs/POINTS_plane/PlaneMethodPoints_coordinates.shx new file mode 100644 index 0000000000000000000000000000000000000000..f84bbc10f4f770401aa7e74997e6dfba40bcb0c1 GIT binary patch literal 108 zcmZQzQ0HR64$NLKGcYg$<*w&%-DvUt;DNdC68x|4WOoee63b2yI&h%yyLPY7Wp+pG L+EGM}fIKb$AnXy$ literal 0 HcmV?d00001 diff --git a/avaframe/data/scarpExample/Inputs/POLYGONS/scarpFluchthorn_perimeter.dbf b/avaframe/data/scarpExample/Inputs/POLYGONS/scarpFluchthorn_perimeter.dbf index 46aebd5506af4feec12348f9f65c46087f3432dc..1d9fbd3ca93e39a02dfc8ac4ec9cc65b1768dec5 100644 GIT binary patch delta 10 RcmebEWnr#k5ueE72>=UT0vP}R delta 10 RcmebEWnr%6VV%h02>=T?0uBHG diff --git a/avaframe/data/scarpExample/Inputs/POLYGONS/scarpFluchthorn_perimeter.prj b/avaframe/data/scarpExample/Inputs/POLYGONS/scarpFluchthorn_perimeter.prj new file mode 100644 index 000000000..f45cbadf0 --- /dev/null +++ b/avaframe/data/scarpExample/Inputs/POLYGONS/scarpFluchthorn_perimeter.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]] \ No newline at end of file diff --git a/avaframe/data/scarpExample/Inputs/POLYGONS/scarpFluchthorn_perimeter.shp b/avaframe/data/scarpExample/Inputs/POLYGONS/scarpFluchthorn_perimeter.shp index a07334ed12f90b46085244378e5884d8a7a9554c..e633df8e2d4c254ff24a439c2439eea8d7f1ff6a 100644 GIT binary patch literal 236 zcmZQzQ0HR64$59IGcd3MB&;byYzn0zcRN}|AOMdM;kQIHYlR2as8}dD4>S|2c4g?K9iq>cg03ffRz&fdEV`%$|AmcT?-t_aES#^Sb^7&|a83 ZU}niZX!gJU_P_zty8p+Y0?kI(4*)JoQeFT6 literal 236 zcmZQzQ0HR64$59IGcd3MB&;byYzn0zc$sV0Y!deFp)G@7m^5ihPBX;d5 zqKrVE1F~6CILrbm1gQf7n7uH2&Yf1WYjikxK-T%P>>i-KFn7Srl6|xN){I$)4tT0Q LPrV6rC%S$BZ|Y5i diff --git a/avaframe/data/scarpExample/Inputs/POLYGONS/scarpFluchthorn_perimeter.shx b/avaframe/data/scarpExample/Inputs/POLYGONS/scarpFluchthorn_perimeter.shx index c11c1b4094bc5741cfe7aea746a611573d39ec2d..ef40ee0cbeb0437b3a191c8973bafd71d0424774 100644 GIT binary patch delta 36 scmd1FnP4JtD)HmmCBOC^$cjGb_VFgWX=qOd2*QDablp@#02(<32dxJ3=9ko041Fba{vGU diff --git a/avaframe/tests/test_scarp.py b/avaframe/tests/test_scarp.py index 1692b34a3..79031d4f5 100644 --- a/avaframe/tests/test_scarp.py +++ b/avaframe/tests/test_scarp.py @@ -14,7 +14,6 @@ from avaframe.com6RockAvalanche import scarp from avaframe.in2Trans.shpConversion import SHP2Array - # ============================================================================ # Test Fixtures # ============================================================================ @@ -90,9 +89,7 @@ def temp_output_dir(tmp_path): def test_readPerimeterSHP(scarp_test_data): """Test perimeter shapefile reading and rasterization""" # Get paths to test data - perimeterShp = ( - scarp_test_data / "Inputs" / "POLYGONS" / "scarpFluchthorn_perimeter.shp" - ) + perimeterShp = scarp_test_data / "Inputs" / "POLYGONS" / "scarpFluchthorn_perimeter.shp" demPath = scarp_test_data / "Inputs" / "fluchthorn.tif" # Read DEM to get transform and shape @@ -106,9 +103,7 @@ def test_readPerimeterSHP(scarp_test_data): # Assertions assert periData.shape == elevShape, "Perimeter shape should match DEM shape" assert periData.dtype == np.uint8, "Perimeter should be uint8 type" - assert np.all((periData == 0) | (periData == 1)), ( - "Perimeter should only contain 0 and 1" - ) + assert np.all((periData == 0) | (periData == 1)), "Perimeter should only contain 0 and 1" assert np.sum(periData) > 0, "Perimeter should contain some pixels marked as 1" assert np.sum(periData) < periData.size, "Perimeter should not mark all pixels" @@ -116,7 +111,7 @@ def test_readPerimeterSHP(scarp_test_data): def test_plane_parameter_extraction(scarp_test_data): """Test extraction of plane parameters from shapefile""" # Read coordinates shapefile - coordShp = scarp_test_data / "Inputs" / "POINTS" / "points_coordinates.shp" + coordShp = scarp_test_data / "Inputs" / "POINTS_plane" / "PlaneMethodPoints_coordinates.shp" SHPdata = SHP2Array(coordShp) # Extract plane parameters (as done in scarpAnalysisMain) @@ -125,13 +120,9 @@ def test_plane_parameter_extraction(scarp_test_data): planesSlope = list(map(float, SHPdata["dipAngle"])) # Assertions - assert len(planesZseed) == SHPdata["nFeatures"], ( - "Should have zseed for each feature" - ) + assert len(planesZseed) == SHPdata["nFeatures"], "Should have zseed for each feature" assert len(planesDip) == SHPdata["nFeatures"], "Should have dip for each feature" - assert len(planesSlope) == SHPdata["nFeatures"], ( - "Should have slope for each feature" - ) + assert len(planesSlope) == SHPdata["nFeatures"], "Should have slope for each feature" assert SHPdata["nFeatures"] == 1, "Test data should have 1 feature" # Build feature string @@ -147,9 +138,7 @@ def test_plane_parameter_extraction(scarp_test_data): features = ",".join(map(str, planeFeatures)) # Should have 5 parameters per feature - assert len(planeFeatures) == SHPdata["nFeatures"] * 5, ( - "Should have 5 params per plane" - ) + assert len(planeFeatures) == SHPdata["nFeatures"] * 5, "Should have 5 params per plane" assert len(features) > 0, "Feature string should not be empty" assert features.count(",") == len(planeFeatures) - 1, "Comma count should match" @@ -173,9 +162,7 @@ def test_plane_geometry_calculations(): west, north = 150.0, 250.0 # Point coordinates # Plane equation: z = zSeed + (north - ySeed) * betaY - (west - xSeed) * betaX - scarpVal = ( - zSeed + (north - ySeed) * expected_betaY - (west - xSeed) * expected_betaX - ) + scarpVal = zSeed + (north - ySeed) * expected_betaY - (west - xSeed) * expected_betaX # Manual calculation expected_scarpVal = 1000.0 + (50.0 * expected_betaY) - (50.0 * expected_betaX) @@ -183,9 +170,7 @@ def test_plane_geometry_calculations(): assert abs(scarpVal - expected_scarpVal) < 0.001, "Plane equation should be correct" -def test_calculateScarpWithPlanes_single_plane( - mock_dem, mock_perimeter, mock_transform -): +def test_calculateScarpWithPlanes_single_plane(mock_dem, mock_perimeter, mock_transform): """Test plane-based scarp calculation with single plane""" # Create a simple plane definition # Place seed point at center of grid with known parameters @@ -196,9 +181,7 @@ def test_calculateScarpWithPlanes_single_plane( planes = f"{xSeed},{ySeed},{zSeed},{dip},{slope}" # Call function under test - scarpData = scarp.calculateScarpWithPlanes( - mock_dem, mock_perimeter, mock_transform, planes - ) + scarpData = scarp.calculateScarpWithPlanes(mock_dem, mock_perimeter, mock_transform, planes) # Assertions assert scarpData.shape == mock_dem.shape, "Scarp should have same shape as DEM" @@ -206,20 +189,18 @@ def test_calculateScarpWithPlanes_single_plane( # Outside perimeter, scarp should equal DEM outside_mask = mock_perimeter == 0 - assert np.allclose(scarpData[outside_mask], mock_dem[outside_mask]), ( - "Outside perimeter, scarp should equal DEM" - ) + assert np.allclose( + scarpData[outside_mask], mock_dem[outside_mask] + ), "Outside perimeter, scarp should equal DEM" # Inside perimeter, scarp should be <= DEM inside_mask = mock_perimeter > 0 - assert np.all(scarpData[inside_mask] <= mock_dem[inside_mask] + 0.001), ( - "Inside perimeter, scarp should not exceed DEM" - ) + assert np.all( + scarpData[inside_mask] <= mock_dem[inside_mask] + 0.001 + ), "Inside perimeter, scarp should not exceed DEM" -def test_calculateScarpWithPlanes_multiple_planes( - mock_dem, mock_perimeter, mock_transform -): +def test_calculateScarpWithPlanes_multiple_planes(mock_dem, mock_perimeter, mock_transform): """Test plane calculation with multiple planes (maximum selection)""" # Create two planes with different seed points # Plane 1 @@ -233,18 +214,16 @@ def test_calculateScarpWithPlanes_multiple_planes( planes = f"{xSeed1},{ySeed1},{zSeed1},{dip1},{slope1},{xSeed2},{ySeed2},{zSeed2},{dip2},{slope2}" # Call function under test - scarpData = scarp.calculateScarpWithPlanes( - mock_dem, mock_perimeter, mock_transform, planes - ) + scarpData = scarp.calculateScarpWithPlanes(mock_dem, mock_perimeter, mock_transform, planes) # Assertions assert scarpData.shape == mock_dem.shape, "Scarp should have same shape as DEM" # Outside perimeter, scarp should equal DEM outside_mask = mock_perimeter == 0 - assert np.allclose(scarpData[outside_mask], mock_dem[outside_mask]), ( - "Outside perimeter, scarp should equal DEM" - ) + assert np.allclose( + scarpData[outside_mask], mock_dem[outside_mask] + ), "Outside perimeter, scarp should equal DEM" def test_calculateScarpWithPlanes_edge_cases(mock_dem, mock_perimeter, mock_transform): @@ -254,23 +233,17 @@ def test_calculateScarpWithPlanes_edge_cases(mock_dem, mock_perimeter, mock_tran dip, slope = 0.0, 0.0 # Zero slope planes = f"{xSeed},{ySeed},{zSeed},{dip},{slope}" - scarpData = scarp.calculateScarpWithPlanes( - mock_dem, mock_perimeter, mock_transform, planes - ) + scarpData = scarp.calculateScarpWithPlanes(mock_dem, mock_perimeter, mock_transform, planes) # With zero slope, plane should be horizontal at zSeed inside_mask = mock_perimeter > 0 expected = np.minimum(mock_dem[inside_mask], zSeed) - assert np.allclose(scarpData[inside_mask], expected), ( - "Zero slope should create horizontal plane" - ) + assert np.allclose(scarpData[inside_mask], expected), "Zero slope should create horizontal plane" # Test case 2: Vertical dip (90 degrees) dip, slope = 90.0, 10.0 planes = f"{xSeed},{ySeed},{zSeed},{dip},{slope}" - scarpData = scarp.calculateScarpWithPlanes( - mock_dem, mock_perimeter, mock_transform, planes - ) + scarpData = scarp.calculateScarpWithPlanes(mock_dem, mock_perimeter, mock_transform, planes) # Should not crash and produce valid output assert scarpData.shape == mock_dem.shape, "Should handle 90 degree dip" @@ -282,9 +255,7 @@ def test_calculateScarpWithPlanes_edge_cases(mock_dem, mock_perimeter, mock_tran # ============================================================================ -def test_scarpAnalysisMain_plane_method( - scarp_test_data, scarp_config, tmp_path, caplog -): +def test_scarpAnalysisMain_plane_method(scarp_test_data, scarp_config, tmp_path, caplog): """End-to-end test using plane method with real test data""" # Set caplog to capture INFO level logs caplog.set_level("INFO") @@ -293,6 +264,24 @@ def test_scarpAnalysisMain_plane_method( test_dir = tmp_path / "scarpTest" shutil.copytree(scarp_test_data, test_dir) + # Ensure the plane-method test uses the plane coordinate shapefile. + # The test data stores plane/ellipsoid coordinate shapefiles in separate directories. + pointsDir = test_dir / "Inputs" / "POINTS" + planePointsDir = test_dir / "Inputs" / "POINTS_plane" + + # Remove the ellipsoid coordinate shapefile from POINTS so `scarpAnalysisMain()` + # doesn't pick it up when running in plane mode. + for ext in [".shp", ".shx", ".dbf", ".prj", ".cpg"]: + p = pointsDir / f"EllipsoidMethodPoints_coordinates{ext}" + if p.exists(): + p.unlink() + + # Copy plane coordinate shapefile into the location `scarpAnalysisMain()` expects. + for ext in [".shp", ".shx", ".dbf", ".prj", ".cpg"]: + src = planePointsDir / f"PlaneMethodPoints_coordinates{ext}" + if src.exists(): + shutil.copy2(src, pointsDir / src.name) + # Run scarp analysis scarp.scarpAnalysisMain(scarp_config, str(test_dir)) @@ -313,18 +302,14 @@ def test_scarpAnalysisMain_plane_method( assert src.height == 220, "Output should have correct height" assert src.width == 300, "Output should have correct width" - assert np.all(np.isfinite(scarp_data[scarp_data != src.nodata])), ( - "Scarp data should be finite" - ) + assert np.all(np.isfinite(scarp_data[scarp_data != src.nodata])), "Scarp data should be finite" with rasterio.open(hrel_file) as src: hrel_data = src.read(1) # hRel should be non-negative where valid (DEM - scarp >= 0) valid_mask = hrel_data != src.nodata - assert np.all(hrel_data[valid_mask] >= -0.001), ( - "hRel values should be non-negative" - ) + assert np.all(hrel_data[valid_mask] >= -0.001), "hRel values should be non-negative" # Check logging output assert "Perimeterfile is:" in caplog.text, "Should log perimeter file" @@ -336,9 +321,7 @@ def test_scarpAnalysisMain_plane_method( # ============================================================================ -def test_scarpAnalysisMain_missing_perimeter_file( - scarp_config, temp_output_dir, caplog -): +def test_scarpAnalysisMain_missing_perimeter_file(scarp_config, temp_output_dir, caplog): """Test error handling when perimeter shapefile is missing""" # Create a minimal test setup with missing perimeter file # Create a dummy DEM @@ -354,14 +337,12 @@ def test_scarpAnalysisMain_missing_perimeter_file( scarp.scarpAnalysisMain(scarp_config, str(temp_output_dir)) # Check that error was logged - assert "not found" in caplog.text.lower() or "error" in caplog.text.lower(), ( - "Should log error about missing file" - ) + assert ( + "not found" in caplog.text.lower() or "error" in caplog.text.lower() + ), "Should log error about missing file" -def test_scarpAnalysisMain_invalid_shapefile_attributes( - scarp_config, temp_output_dir, caplog -): +def test_scarpAnalysisMain_invalid_shapefile_attributes(scarp_config, temp_output_dir, caplog): """Test validation of shapefile attributes for plane method""" # This test would require creating a shapefile with missing attributes # For now, we test the error path by checking the ValueError is raised @@ -375,9 +356,7 @@ def test_scarpAnalysisMain_invalid_shapefile_attributes( assert True, "Attribute validation tested through code inspection" -def test_scarpAnalysisMain_useShapefiles_false( - scarp_config, scarp_test_data, tmp_path, caplog -): +def test_scarpAnalysisMain_useShapefiles_false(scarp_config, scarp_test_data, tmp_path, caplog): """Test configuration validation when useShapefiles is False""" # Copy test data to temporary directory to have a valid DEM test_dir = tmp_path / "scarpTestNoShapefiles" @@ -394,9 +373,7 @@ def test_scarpAnalysisMain_useShapefiles_false( pass # Expected to fail after logging error # Check error message was logged - assert "Shapefile option not selected" in caplog.text, ( - "Should log error about shapefile option" - ) + assert "Shapefile option not selected" in caplog.text, "Should log error about shapefile option" def test_scarpAnalysisMain_invalid_method(scarp_test_data, scarp_config, tmp_path): @@ -452,9 +429,9 @@ def test_error_message_attribute_names(): # The error message should reference 'dipAngle' not 'dipangle' if line_90_match: - assert "'dipAngle'" in line_90_match or "'dipangle'" in line_90_match, ( - f"Line 90 should reference dipAngle attribute: {line_90_match}" - ) + assert ( + "'dipAngle'" in line_90_match or "'dipangle'" in line_90_match + ), f"Line 90 should reference dipAngle attribute: {line_90_match}" # Check line 121 error message line_121_match = None @@ -465,6 +442,6 @@ def test_error_message_attribute_names(): # The error message should reference 'rotAngle' not 'rotangle' if line_121_match: - assert "'rotAngle'" in line_121_match or "'rotangle'" in line_121_match, ( - f"Line 121 should reference rotAngle attribute: {line_121_match}" - ) + assert ( + "'rotAngle'" in line_121_match or "'rotangle'" in line_121_match + ), f"Line 121 should reference rotAngle attribute: {line_121_match}"