Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RasterDataset: better error message when no data found #1193

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions torchgeo/datasets/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down