Skip to content

Commit

Permalink
enh: support passing a single file to concatenated_hdf5_data
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Oct 25, 2024
1 parent b41ed45 commit 0c4b365
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
0.25.4
- enh: support passing a single file to `concatenated_hdf5_data`
0.25.3
- enh: request single threaded operations when going into mp.Process (#17)
- enh: new module `dcnum.single_thread_osenv`
Expand Down
7 changes: 5 additions & 2 deletions src/dcnum/read/hdf5_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,11 @@ def concatenated_hdf5_data(paths: List[pathlib.Path],
raise ValueError(
f"Invalid type for `path_out`: {type(path_out)} ({path_out}")

if len(paths) <= 1:
raise ValueError("Please specify at least two files in `paths`!")
if len(paths) == 0:
raise ValueError("Please specify at least one file in `paths`!")
elif len(paths) == 1:
warnings.warn("Only one file passed to `concatenated_hdf5_data`; this "
"is equivalent to using `HDF5Data`, but slower.")

frames = []

Expand Down
10 changes: 8 additions & 2 deletions tests/test_read_concat_hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@ def test_concat_invalid_input_path():


def test_concat_invalid_input_path_number():
with pytest.raises(ValueError, match="Please specify at least one"):
read.concatenated_hdf5_data([])


def test_concat_invalid_input_path_number_warn():
path = retrieve_data("fmt-hdf5_cytoshot_full-features_2023.zip")
with pytest.raises(ValueError, match="Please specify at least two"):
read.concatenated_hdf5_data([path])
with pytest.warns(UserWarning, match="is equivalent to using"):
hd = read.concatenated_hdf5_data([path])
assert len(hd) == 40


def test_concat_specify_input_feature_number():
Expand Down

0 comments on commit 0c4b365

Please sign in to comment.