Skip to content

Commit

Permalink
Add h-maxima test demonstrating floating point failures as reported in
Browse files Browse the repository at this point in the history
  • Loading branch information
HazenBabcock committed Mar 4, 2020
1 parent 764da62 commit bea7b22
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions skimage/morphology/tests/test_extrema.py
Expand Up @@ -171,6 +171,25 @@ def test_extrema_float(self):
error = diff(expected_result, out)
assert error < eps

def test_h_maxima_float(self):
"""specific tests for h-maxima float type"""
w = 10
x, y = np.mgrid[0:w,0:w]
data = 20 - 0.2*((x - w/2)**2 + (y-w/2)**2)
data[2:4,2:4] = 40
data[2:4,7:9] = 60
data[7:9,2:4] = 80
data[7:9,7:9] = 100
data = data.astype(np.float32)

expected_result = np.zeros_like(data)
expected_result[(data>19.9)] = 1.0

for h in [1.0e-12, 1.0e-6, 1.0e-3, 1.0e-2, 1.0e-1, 0.1]:
out = extrema.h_maxima(data, h)
error = diff(expected_result, out)
assert error < eps


class TestLocalMaxima(unittest.TestCase):
"""Some tests for local_minima are included as well."""
Expand Down

0 comments on commit bea7b22

Please sign in to comment.