diff --git a/torchgeo/datasets/geo.py b/torchgeo/datasets/geo.py index 26a035d427d..cdce123ce8f 100644 --- a/torchgeo/datasets/geo.py +++ b/torchgeo/datasets/geo.py @@ -435,6 +435,7 @@ def __init__( cache: if True, cache file handle to speed up repeated sampling Raises: + AssertionError: If *bands* are invalid. DatasetNotFoundError: If dataset is not found. .. versionchanged:: 0.5 @@ -446,6 +447,9 @@ def __init__( self.bands = bands or self.all_bands self.cache = cache + if self.all_bands: + assert set(self.bands) <= set(self.all_bands) + # Populate the dataset index i = 0 filename_regex = re.compile(self.filename_regex, re.VERBOSE)