Skip to content

Commit

Permalink
update unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
trchudley committed Jan 27, 2025
1 parent a2dac45 commit 3cfcf0d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
10 changes: 5 additions & 5 deletions tests/test_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_geomorphometry():

variable_min_max = {
"slope": (0.0, 24.721811294555664),
"aspect": (0.0, 360.0), # (1.3660377589985728e-05, 359.9999694824219),
"aspect": (0.0, 360.0), # (1.3660377589985728e-05, 359.9999694824219),
"hillshade": (0.0, 1.0),
"horizontal_curvature": (-0.0007999989320524037, 0.0007856095326133072),
"vertical_curvature": (-0.027519449591636658, 0.022581202909350395),
Expand All @@ -95,7 +95,7 @@ def test_geomorphometry():
for variables in variable_min_max.keys():
min_val = dem[variables].min().item()
max_val = dem[variables].max().item()
print(f'{variables} | min: {min_val} | max: {max_val}')
print(f"{variables} | min: {min_val} | max: {max_val}")
assert_allclose(min_val, variable_min_max[variables][0])
assert_allclose(max_val, variable_min_max[variables][1])

Expand All @@ -108,12 +108,12 @@ def test_coregistration():
mask_gdf = gpd.GeoDataFrame(geometry=[box(-200, -100, 0, 100)], crs=3413)
mask = pdt.data.bedrock_mask_from_vector(mask_gdf, dem_1)

dem_2_coreg = dem_2.pdt.coregister(dem_1, mask)
dem_2_coreg = dem_2.pdt.coregister_dems(dem_1, mask)

diff = (dem_2 - dem_1).mean().item()
# diff = (dem_2 - dem_1).mean().item()
diff_coreg = (dem_2_coreg - dem_1).mean().item()

expected_diff = 15.476494902013904
# expected_diff = 15.476494902013904
expected_diff_coreg = 0.19603341170854155

# print(diff, corrected_diff)
Expand Down
29 changes: 25 additions & 4 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,44 @@
SAMPLE_INDEX_FPATH = resources.files("pdemtools.test_data").joinpath(SAMPLE_INDEX_FNAME)


def test_search():
def test_search_stac():

bounds = (459000, -2539000, 473000, -2528000)

gdf = pdt.search(
SAMPLE_INDEX_FPATH,
bounds,
dataset="arcticdem",
bounds=bounds,
dates="20170101/20221231",
months=[6, 7, 8, 9],
years=[2017, 2021],
baseline_max_hours=24,
sensors=["WV03", "WV02", "WV01"],
accuracy=2,
min_aoi_frac=0.7,
)

assert len(gdf) == 6


def test_search_index():

bounds = (459000, -2539000, 473000, -2528000)

gdf = pdt.search(
dataset="arcticdem",
bounds=bounds,
dates="20170101/20221231",
months=[6, 7, 8, 9],
years=[2017, 2021],
baseline_max_hours=24,
sensors=["WV03", "WV02", "WV01"],
min_aoi_frac=0.7,
index_fpath=SAMPLE_INDEX_FPATH,
)

assert len(gdf) == 6


if __name__ == "__main__":
test_search()
test_search_stac()
test_search_index()

0 comments on commit 3cfcf0d

Please sign in to comment.