Skip to content

Commit

Permalink
Add checks to test GlacioHack#127 is resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
rhugonnet committed Mar 15, 2024
1 parent 286b13e commit 21f70ea
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/test_raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1304,15 +1304,23 @@ def test_crop(self, data: list[str]) -> None:
assert r_crop_unloaded.shape == r_crop_loaded.shape
assert r_crop_unloaded.transform == r_crop_loaded.transform

# - Check warning is raised for pixel interpretation of match-reference geometry -
# -- Check warning for area_or_point works -- #
# - Check related to pixel interpretation -

# Check warning for a different area_or_point for the match-reference geometry works
r.set_area_or_point("Area", shift_area_or_point=False)
r2 = r.copy()
r2.set_area_or_point("Point", shift_area_or_point=False)

with pytest.warns(UserWarning, match='One raster has a pixel interpretation "Area" and the other "Point".*'):
r.crop(r2)

# Check that cropping preserves the interpretation
crop_geom = [crop_geom[0] + r.res[0], crop_geom[1], crop_geom[2], crop_geom[3]]
r_crop = r.crop(crop_geom)
assert r_crop.area_or_point == "Area"
r2_crop = r2.crop(crop_geom)
assert r2_crop.area_or_point == "Point"

@pytest.mark.parametrize("example", [landsat_b4_path, aster_dem_path, landsat_rgb_path]) # type: ignore
def test_shift(self, example: str) -> None:
"""Tests shift works as intended"""
Expand Down Expand Up @@ -1696,6 +1704,12 @@ def test_reproject(self, example: str) -> None:
with pytest.warns(UserWarning, match='One raster has a pixel interpretation "Area" and the other "Point".*'):
r.reproject(r2)

# Check that reprojecting preserves interpretation
r_reproj = r.reproject(res=r.res[0] * 2)
assert r_reproj.area_or_point == "Area"
r2_reproj = r2.reproject(res=r2.res[0] * 2)
assert r2_reproj.area_or_point == "Point"

@pytest.mark.parametrize("example", [landsat_b4_path, aster_dem_path]) # type: ignore
def test_intersection(self, example: list[str]) -> None:
"""Check the behaviour of the intersection function"""
Expand Down

0 comments on commit 21f70ea

Please sign in to comment.