From 4dfbcd5fc6e84fa1d7527d60fff9d05acd3c55f1 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Tue, 28 Mar 2023 20:27:18 -0500 Subject: [PATCH] GeoDataset: better error message when no data found (#1193) --- torchgeo/datasets/geo.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/torchgeo/datasets/geo.py b/torchgeo/datasets/geo.py index aede7e6a405..18b3cd9310c 100644 --- a/torchgeo/datasets/geo.py +++ b/torchgeo/datasets/geo.py @@ -364,9 +364,10 @@ def __init__( i += 1 if i == 0: - raise FileNotFoundError( - f"No {self.__class__.__name__} data was found in '{root}'" - ) + msg = f"No {self.__class__.__name__} data was found in `root='{self.root}'`" + if self.bands: + msg += f" with `bands={self.bands}`" + raise FileNotFoundError(msg) if not self.separate_files: self.band_indexes = None @@ -582,9 +583,8 @@ def __init__( i += 1 if i == 0: - raise FileNotFoundError( - f"No {self.__class__.__name__} data was found in '{root}'" - ) + msg = f"No {self.__class__.__name__} data was found in `root='{root}'`" + raise FileNotFoundError(msg) self._crs = crs