Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove GDAL and RichDEM dependancy from tests #675

Merged
merged 7 commits into from
Jan 23, 2025
Prev Previous commit
Next Next commit
test: minor
  • Loading branch information
vschaffn committed Jan 22, 2025
commit beeb3b66cbcc877f5958c0c5e908b7470fa2181c
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@

# Define a URL to the xdem-data repository's test data
_TESTDATA_REPO_URL = "https://github.com/vschaffn/xdem-data/tarball/2-richdem_gdal"
_COMMIT_HASH = "ca9d7e34294cf57c00cea4adbf4ee634a63e20d7"
_COMMIT_HASH = "31a7159c982cec4b352f0de82bd4e0be61db3afe"


def download_test_data(overwrite: bool = False) -> None:
13 changes: 0 additions & 13 deletions tests/test_terrain.py
Original file line number Diff line number Diff line change
@@ -143,26 +143,13 @@ def test_attribute_functions_against_richdem(self, attribute: str, get_test_data
"planform_curvature": lambda dem: xdem.terrain.planform_curvature(dem.data, resolution=dem.res),
}

# Functions for RichDEM wrapper methods
# functions_richdem = {
# "slope_Horn": lambda dem: get_terrain_attribute_richdem(dem, attribute="slope", degrees=True),
# "aspect_Horn": lambda dem: get_terrain_attribute_richdem(dem, attribute="aspect", degrees=True),
# "hillshade_Horn": lambda dem: get_terrain_attribute_richdem(dem, attribute="hillshade"),
# "curvature": lambda dem: get_terrain_attribute_richdem(dem, attribute="curvature"),
# "profile_curvature": lambda dem: get_terrain_attribute_richdem(dem, attribute="profile_curvature"),
# "planform_curvature": lambda dem: get_terrain_attribute_richdem(
# dem, attribute="planform_curvature", degrees=True
# ),
# }

# Copy the DEM to ensure that the inter-test state is unchanged, and because the mask will be modified.
dem = self.dem.copy()

# Derive the attribute using both RichDEM and xdem
attr_xdem = gu.raster.get_array_and_mask(functions_xdem[attribute](dem))[0].squeeze()
attr_richdem_rst = gu.Raster(get_test_data_path(os.path.join("richdem", f"{attribute}.tif")), load_data=True)
attr_richdem = gu.raster.get_array_and_mask(attr_richdem_rst)[0].squeeze()
# attr_richdem = gu.raster.get_array_and_mask(functions_richdem[attribute](dem))[0].squeeze()

# We compute the difference and keep only valid values
diff = attr_xdem - attr_richdem