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

Commit

Permalink
Merge pull request #131 from dstansby/data-dim-error
Browse files Browse the repository at this point in the history
Test for error when data dimensionality is wrong
  • Loading branch information
alessandrofelder authored Apr 4, 2023
2 parents a345826 + a94faf2 commit 1fce9cd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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)

0 comments on commit 1fce9cd

Please sign in to comment.