Skip to content

Commit

Permalink
Adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rhugonnet committed Nov 18, 2024
1 parent c177d8b commit cf3da60
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
15 changes: 3 additions & 12 deletions tests/test_dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,11 @@ def test_init(self) -> None:
dem3 = DEM(r)
assert isinstance(dem3, DEM)

# From SatelliteImage
with warnings.catch_warnings():
warnings.filterwarnings("ignore", "Parse metadata from file not implemented")
img = gu.SatelliteImage(fn_img)
dem4 = DEM(img)
assert isinstance(dem4, DEM)

list_dem = [dem, dem2, dem3, dem4]
list_dem = [dem, dem2, dem3]

# Check all attributes
attrs = [at for at in _default_rio_attrs if at not in ["name", "dataset_mask", "driver"]]
all_attrs = attrs + gu.raster.satimg.satimg_attrs + xdem.dem.dem_attrs
all_attrs = attrs + xdem.dem.dem_attrs
for attr in all_attrs:
attrs_per_dem = [idem.__getattribute__(attr) for idem in list_dem]
assert all(at == attrs_per_dem[0] for at in attrs_per_dem)
Expand All @@ -59,15 +52,13 @@ def test_init(self) -> None:
(
np.array_equal(dem.data, dem2.data, equal_nan=True),
np.array_equal(dem2.data, dem3.data, equal_nan=True),
np.array_equal(dem3.data, dem4.data, equal_nan=True),
)
)

assert np.logical_and.reduce(
(
np.all(dem.data.mask == dem2.data.mask),
np.all(dem2.data.mask == dem3.data.mask),
np.all(dem3.data.mask == dem4.data.mask),
)
)

Expand Down Expand Up @@ -192,7 +183,7 @@ def test_copy(self) -> None:

# using list directly available in Class
attrs = [at for at in _default_rio_attrs if at not in ["name", "dataset_mask", "driver"]]
all_attrs = attrs + gu.raster.satimg.satimg_attrs + xdem.dem.dem_attrs
all_attrs = attrs + xdem.dem.dem_attrs
for attr in all_attrs:
assert r.__getattribute__(attr) == r2.__getattribute__(attr)

Expand Down
9 changes: 1 addition & 8 deletions xdem/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,7 @@ class DEM(Raster): # type: ignore
def __init__(
self,
filename_or_dataset: str | RasterType | rio.io.DatasetReader | rio.io.MemoryFile,
vcrs: Literal["Ellipsoid"]
| Literal["EGM08"]
| Literal["EGM96"]
| VerticalCRS
| str
| pathlib.Path
| int
| None = None,
vcrs: Literal["Ellipsoid", "EGM08", "EGM96"] | VerticalCRS | str | pathlib.Path | int | None = None,
load_data: bool = False,
parse_sensor_metadata: bool = False,
silent: bool = True,
Expand Down

0 comments on commit cf3da60

Please sign in to comment.