Skip to content

Commit

Permalink
fix(io): prevent specifying invalid data_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
kmnhan committed Apr 11, 2024
1 parent a91ad3d commit 701b011
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/erlab/io/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ def load(
single file within a multiple file scan, the default behavior when `single`
is `False` is to return a single concatenated array that contains data from
all files in the same scan. If `single` is set to `True`, only the data from
the file given is returned.
the file given is returned. This argument is ignored when `identifier` is a
number.
**kwargs
Additional keyword arguments are passed to `identify`.
Expand Down Expand Up @@ -423,6 +424,9 @@ def summarize(
Summary of the data in the directory.
"""
if not os.path.isdir(data_dir):
raise FileNotFoundError(f"Directory {data_dir} not found")

pkl_path = os.path.join(data_dir, ".summary.pkl")
df = None
if usecache:
Expand Down Expand Up @@ -846,6 +850,8 @@ def set_data_dir(self, data_dir: str | os.PathLike):
directly, it will not use the default data directory.
"""
if not os.path.isdir(data_dir):
raise FileNotFoundError(f"Directory {data_dir} not found")
self.default_data_dir = data_dir

def load(
Expand Down

0 comments on commit 701b011

Please sign in to comment.