diff --git a/tests/test_dem.py b/tests/test_dem.py index b39dacc3..3a3890db 100644 --- a/tests/test_dem.py +++ b/tests/test_dem.py @@ -7,6 +7,7 @@ import numpy as np import pyproj import pytest +import rasterio as rio from geoutils.georaster.raster import _default_rio_attrs import xdem @@ -65,6 +66,15 @@ def test_init(self) -> None: ) ) + # Check that an error is raised when more than one band is provided + with pytest.raises(ValueError, match="DEM rasters should be composed of one band only"): + xdem.DEM.from_array( + data=np.zeros(shape=(2, 5, 5)), + transform=rio.transform.from_bounds(0, 0, 1, 1, 5, 5), + crs=None, + nodata=None, + ) + def test_copy(self) -> None: """ Test that the copy method works as expected for DEM. In particular diff --git a/xdem/coreg.py b/xdem/coreg.py index 88669b2d..6694cf09 100644 --- a/xdem/coreg.py +++ b/xdem/coreg.py @@ -1401,7 +1401,7 @@ def _fit_func( # Iteratively run the analysis until the maximum iterations or until the error gets low enough if verbose: - print(" Iteratively estimating horizontal shit:") + print(" Iteratively estimating horizontal shift:") # If verbose is True, will use progressbar and print additional statements pbar = trange(self.max_iterations, disable=not verbose, desc=" Progress") diff --git a/xdem/dem.py b/xdem/dem.py index b3e0c24e..00ad79e3 100644 --- a/xdem/dem.py +++ b/xdem/dem.py @@ -83,8 +83,8 @@ def __init__( warnings.filterwarnings("ignore", message="Parse metadata from file not implemented") super().__init__(filename_or_dataset, silent=silent, **kwargs) - # self.nbands can be None when data is not loaded through the Raster class - if self.nbands is not None and self.nbands > 1: + # self.indexes can be None when data is not loaded through the Raster class + if self.indexes is not None and len(self.indexes) > 1: raise ValueError("DEM rasters should be composed of one band only") # user input