From 22ffc20fc44a23450fb312208cc0bb61f3ad1e3d Mon Sep 17 00:00:00 2001 From: kpk09 Date: Sun, 25 Jan 2015 00:15:20 +0000 Subject: [PATCH] Added broken test for feature.peak_local_max when the image is 3D and num_peaks is set. The current code only holds for 2D images. --- skimage/feature/tests/test_peak.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/skimage/feature/tests/test_peak.py b/skimage/feature/tests/test_peak.py index ec130c66..09e52495 100644 --- a/skimage/feature/tests/test_peak.py +++ b/skimage/feature/tests/test_peak.py @@ -82,6 +82,15 @@ def test_num_peaks(): assert (3, 5) in peaks_limited +def test_num_peaks3D(): + # Issue 1354: the old code only hold for 2D arrays + # and this code would die with IndexError + image = np.zeros((10, 10, 100)) + image[5,5,::5] = np.arange(20) + peaks_limited = peak.peak_local_max(image, min_distance=1, num_peaks=2) + assert len(peaks_limited) == 2 + + def test_reorder_labels(): image = np.random.uniform(size=(40, 60)) i, j = np.mgrid[0:40, 0:60]