Raise error for invalid min_distance values

This commit is contained in:
Johannes Schönberger
2016-01-24 10:55:14 +01:00
parent 3f912903cb
commit 88ee3ce96e
2 changed files with 12 additions and 2 deletions
+4 -1
View File
@@ -19,7 +19,7 @@ def peak_local_max(image, min_distance=1, threshold_abs=None,
Parameters
----------
image : ndarray of floats
image : ndarray
Input image.
min_distance : int, optional
Minimum number of pixels separating peaks in a region of `2 *
@@ -93,6 +93,9 @@ def peak_local_max(image, min_distance=1, threshold_abs=None,
"""
if min_distance < 1:
raise ValueError("`min_disance` must greater than 0")
out = np.zeros_like(image, dtype=np.bool)
# In the case of labels, recursively build and return an output
+8 -1
View File
@@ -1,6 +1,6 @@
import numpy as np
from numpy.testing import (assert_array_almost_equal as assert_close,
assert_equal)
assert_equal, assert_raises)
from scipy import ndimage as ndi
from skimage.feature import peak
@@ -309,6 +309,13 @@ def test_4D():
[[5, 5, 5, 5], [15, 15, 15, 15]])
def test_invalid_min_distance():
assert_raises(ValueError, peak.peak_local_max, np.zeros((10, 10)),
min_distance=0)
assert_raises(ValueError, peak.peak_local_max, np.zeros((10, 10)),
min_distance=-1)
if __name__ == '__main__':
from numpy import testing
testing.run_module_suite()