Skip to content

Commit

Permalink
ref: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Jun 25, 2024
1 parent 2042e33 commit b9bcdda
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/dcnum/write/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ class CreatingFileWithoutBasinWarning(UserWarning):
pass


class IgnoringBasinTypeWarning(UserWarning):
"""Issued when a specific basin type is ignored"""
pass


class HDF5Writer:
def __init__(self,
# TODO: make this a mandatory argument when `path` is
Expand Down Expand Up @@ -400,7 +405,8 @@ def copy_basins(h5_src: h5py.File,
mapping=mapping,
)
else:
warnings.warn(f"Ignored basin of type {bn_dict['type']}")
warnings.warn(f"Ignored basin of type '{bn_dict['type']}'",
IgnoringBasinTypeWarning)


def copy_features(h5_src: h5py.File,
Expand Down
4 changes: 4 additions & 0 deletions tests/test_feat_background_bg_sparsemed.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def test_median_sparsemend_full(tmp_path, event_count, kernel_size,
assert output_path.exists()


@pytest.mark.filterwarnings(
"ignore:dcnum.write.writer.CreatingFileWithoutBasinWarning")
def test_median_sparsemend_full_bg_off(tmp_path):
"""Test computation of bg_off"""
event_count = 720
Expand Down Expand Up @@ -93,6 +95,8 @@ def test_median_sparsemend_full_bg_off(tmp_path):
input_data - hd["image_bg"] - hd["bg_off"].reshape(-1, 1, 1) == 0)


@pytest.mark.filterwarnings(
"ignore:dcnum.write.writer.CreatingFileWithoutBasinWarning")
def test_median_sparsemend_full_internal_image_bg(tmp_path):
"""Test computation of internal image_bg feature"""
event_count = 720
Expand Down
2 changes: 2 additions & 0 deletions tests/test_write_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def test_copy_basins_simple():


@pytest.mark.parametrize("store_internal", [True, False])
@pytest.mark.filterwarnings(
"ignore:dcnum.write.writer.IgnoringBasinTypeWarning")
def test_copy_basins_internal(store_internal):
path = retrieve_data(
"fmt-hdf5_cytoshot_full-features_legacy_allev_2023.zip")
Expand Down

0 comments on commit b9bcdda

Please sign in to comment.