mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-11 01:40:28 +08:00
Raise error for invalid min_distance values
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user