Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Test for error when data dimensionality is wrong #131

Merged
merged 1 commit into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/cellfinder_core/detect/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def main(
callback = callback or (lambda *args, **kwargs: None)

if signal_array.ndim != 3:
raise IOError("Input data must be 3D")
raise ValueError("Input data must be 3D")

setup_params = (
signal_array[0, :, :],
Expand Down
15 changes: 15 additions & 0 deletions tests/tests/test_integration/test_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,18 @@ def test_synthetic_data(synthetic_bright_spots):
n_free_cpus=0,
)
assert len(detected) == 8


@pytest.mark.parametrize("ndim", [1, 2, 4])
def test_data_dimension_error(ndim):
# Check for an error when non-3D data input
shape = (2, 3, 4, 5)[:ndim]
signal_array = np.random.randint(
low=0, high=2**16, size=shape, dtype=np.uint16
)
background_array = np.random.randint(
low=0, high=2**16, size=shape, dtype=np.uint16
)

with pytest.raises(ValueError, match="Input data must be 3D"):
main(signal_array, background_array, voxel_sizes)