Add tests for priority-flood numba/Python parity and _strip_lidar_ext
This commit is contained in:
@ -548,3 +548,22 @@ class TestPureDtm:
|
||||
vals = sorted(float(v) for v in arr.flatten())
|
||||
assert len(vals) == 4
|
||||
assert vals[-1] == 10.0
|
||||
|
||||
|
||||
class TestStripLidarExt:
|
||||
def test_copc_laz(self):
|
||||
from lidar_pipeline.dtm import _strip_lidar_ext
|
||||
assert _strip_lidar_ext("LHD_FXX_1000_6881_PTS_LAMB93_IGN69.copc.laz") == "LHD_FXX_1000_6881_PTS_LAMB93_IGN69"
|
||||
|
||||
def test_laz(self):
|
||||
from lidar_pipeline.dtm import _strip_lidar_ext
|
||||
assert _strip_lidar_ext("file.laz") == "file"
|
||||
|
||||
def test_las(self):
|
||||
from lidar_pipeline.dtm import _strip_lidar_ext
|
||||
assert _strip_lidar_ext("file.las") == "file"
|
||||
|
||||
def test_path_object(self):
|
||||
from lidar_pipeline.dtm import _strip_lidar_ext
|
||||
from pathlib import Path
|
||||
assert _strip_lidar_ext(Path("/data/input/file.copc.laz")) == "file"
|
||||
|
||||
@ -326,3 +326,44 @@ def test_ray_trace_horizons_reraises_non_oom(monkeypatch):
|
||||
assert False, "ValueError attendue"
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
|
||||
class TestPriorityFlood:
|
||||
def test_numba_matches_python(self):
|
||||
"""Le résultat numba et python sont identiques sur un DEM avec un puits."""
|
||||
from lidar_pipeline.visualizations import _priority_flood_numba, _priority_flood_python
|
||||
|
||||
dem = np.zeros((20, 20), dtype=np.float64)
|
||||
dem[10, 10] = -5.0
|
||||
dem[9:12, 9:12] = -3.0
|
||||
nodata = np.zeros((20, 20), dtype=bool)
|
||||
|
||||
result_numba = _priority_flood_numba(dem.copy(), nodata)
|
||||
result_python = _priority_flood_python(dem.copy(), nodata)
|
||||
|
||||
if result_numba is not None:
|
||||
assert np.allclose(result_numba, result_python)
|
||||
|
||||
def test_pit_is_filled(self):
|
||||
"""Un puits isolé est ramené au niveau de son bord."""
|
||||
from lidar_pipeline.visualizations import _priority_flood
|
||||
|
||||
dem = np.full((10, 10), 5.0, dtype=np.float64)
|
||||
dem[5, 5] = 1.0
|
||||
nodata = np.zeros((10, 10), dtype=bool)
|
||||
|
||||
result = _priority_flood(dem, nodata)
|
||||
assert result[5, 5] == 5.0
|
||||
|
||||
def test_nodata_cells_untouched(self):
|
||||
"""Les cellules nodata ne sont jamais modifiées."""
|
||||
from lidar_pipeline.visualizations import _priority_flood
|
||||
|
||||
dem = np.full((10, 10), 5.0, dtype=np.float64)
|
||||
dem[5, 5] = 1.0
|
||||
nodata = np.zeros((10, 10), dtype=bool)
|
||||
nodata[2, 2] = True
|
||||
dem[2, 2] = 999.0
|
||||
|
||||
result = _priority_flood(dem, nodata)
|
||||
assert result[2, 2] == 999.0
|
||||
|
||||
Reference in New Issue
Block a user