From 8084faf1f69c2c4ba79b6e85c7a2a06e1e7c77b8 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 26 Aug 2012 16:33:25 -0400 Subject: [PATCH 1/2] BUG: Fix division error for Python 3 --- skimage/morphology/greyreconstruct.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skimage/morphology/greyreconstruct.py b/skimage/morphology/greyreconstruct.py index bf3caffe..9e447800 100644 --- a/skimage/morphology/greyreconstruct.py +++ b/skimage/morphology/greyreconstruct.py @@ -133,7 +133,7 @@ def reconstruction(seed, mask, method='dilation', selem=None, offset=None): if offset == None: if not all([d % 2 == 1 for d in selem.shape]): ValueError("Footprint dimensions must all be odd") - offset = np.array([d / 2 for d in selem.shape]) + offset = np.array([d // 2 for d in selem.shape]) # Cross out the center of the selem selem[[slice(d, d + 1) for d in offset]] = False From 7d8bc483787a2241e861b099a4ca28ceee1d8842 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Sun, 26 Aug 2012 16:36:28 -0400 Subject: [PATCH 2/2] ENH: Change assert statement for better error output --- skimage/morphology/tests/test_reconstruction.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/skimage/morphology/tests/test_reconstruction.py b/skimage/morphology/tests/test_reconstruction.py index 74f61b9f..8e40ac67 100644 --- a/skimage/morphology/tests/test_reconstruction.py +++ b/skimage/morphology/tests/test_reconstruction.py @@ -15,19 +15,19 @@ from skimage.morphology.greyreconstruct import reconstruction def test_zeros(): """Test reconstruction with image and mask of zeros""" - assert np.all(reconstruction(np.zeros((5, 7)), np.zeros((5, 7))) == 0) + assert_close(reconstruction(np.zeros((5, 7)), np.zeros((5, 7))), 0) def test_image_equals_mask(): """Test reconstruction where the image and mask are the same""" - assert np.all(reconstruction(np.ones((7, 5)), np.ones((7, 5))) == 1) + assert_close(reconstruction(np.ones((7, 5)), np.ones((7, 5))), 1) def test_image_less_than_mask(): """Test reconstruction where the image is uniform and less than mask""" image = np.ones((5, 5)) mask = np.ones((5, 5)) * 2 - assert np.all(reconstruction(image, mask) == 1) + assert_close(reconstruction(image, mask), 1) def test_one_image_peak(): @@ -35,7 +35,7 @@ def test_one_image_peak(): image = np.ones((5, 5)) image[2, 2] = 2 mask = np.ones((5, 5)) * 3 - assert np.all(reconstruction(image, mask) == 2) + assert_close(reconstruction(image, mask), 2) def test_two_image_peaks(): @@ -60,13 +60,13 @@ def test_two_image_peaks(): [1, 1, 1, 1, 1, 3, 3, 3], [1, 1, 1, 1, 1, 3, 3, 3], [1, 1, 1, 1, 1, 3, 3, 3]]) - assert np.all(reconstruction(image, mask) == expected) + assert_close(reconstruction(image, mask), expected) def test_zero_image_one_mask(): """Test reconstruction with an image of all zeros and a mask that's not""" result = reconstruction(np.zeros((10, 10)), np.ones((10, 10))) - assert np.all(result == 0) + assert_close(result, 0) def test_fill_hole():