From 2058fe23cbbaec3ae89462f28bb54365c859c51e Mon Sep 17 00:00:00 2001 From: Pratap Vardhan Date: Sun, 14 Dec 2014 01:17:27 +0530 Subject: [PATCH 1/2] CLN: Minor cleanup - unused imports, pep8 --- skimage/morphology/tests/test_selem.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/skimage/morphology/tests/test_selem.py b/skimage/morphology/tests/test_selem.py index 7895fa58..ef010123 100644 --- a/skimage/morphology/tests/test_selem.py +++ b/skimage/morphology/tests/test_selem.py @@ -1,12 +1,14 @@ -# Author: Damian Eads +""" +Tests for Morphological structuring elements +(skimage.morphology.selem) +Author: Damian Eads +""" import os.path import numpy as np -from numpy.testing import * +from numpy.testing import assert_equal -from skimage import data_dir -from skimage.io import * from skimage import data_dir from skimage.morphology import selem @@ -32,7 +34,7 @@ class TestSElem(): for arrname in sorted(matlab_masks): expected_mask = matlab_masks[arrname] actual_mask = func(k) - if (expected_mask.shape == (1,)): + if expected_mask.shape == (1,): expected_mask = expected_mask[:, np.newaxis] assert_equal(expected_mask, actual_mask) k = k + 1 @@ -43,15 +45,15 @@ class TestSElem(): for arrname in sorted(matlab_masks): expected_mask = matlab_masks[arrname] actual_mask = func(k) - if (expected_mask.shape == (1,)): + if expected_mask.shape == (1,): expected_mask = expected_mask[:, np.newaxis] # Test center slice for each dimension. This gives a good # indication of validity without the need for a 3D reference # mask. c = int(expected_mask.shape[0]/2) - assert_equal(expected_mask, actual_mask[c,:,:]) - assert_equal(expected_mask, actual_mask[:,c,:]) - assert_equal(expected_mask, actual_mask[:,:,c]) + assert_equal(expected_mask, actual_mask[c, :, :]) + assert_equal(expected_mask, actual_mask[:, c, :]) + assert_equal(expected_mask, actual_mask[:, :, c]) k = k + 1 def test_selem_disk(self): From 9d6516903dd63139e788d2c32130049a6ba1d6a1 Mon Sep 17 00:00:00 2001 From: Pratap Vardhan Date: Sun, 14 Dec 2014 01:28:09 +0530 Subject: [PATCH 2/2] DOC: Add test functions docstrings --- skimage/morphology/tests/test_selem.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/skimage/morphology/tests/test_selem.py b/skimage/morphology/tests/test_selem.py index ef010123..7f4cc7c3 100644 --- a/skimage/morphology/tests/test_selem.py +++ b/skimage/morphology/tests/test_selem.py @@ -16,12 +16,14 @@ from skimage.morphology import selem class TestSElem(): def test_square_selem(self): + """Test square structuring elements""" for k in range(0, 5): actual_mask = selem.square(k) expected_mask = np.ones((k, k), dtype='uint8') assert_equal(expected_mask, actual_mask) def test_rectangle_selem(self): + """Test rectangle structuring elements""" for i in range(0, 5): for j in range(0, 5): actual_mask = selem.rectangle(i, j) @@ -57,18 +59,23 @@ class TestSElem(): k = k + 1 def test_selem_disk(self): + """Test disk structuring elements""" self.strel_worker("disk-matlab-output.npz", selem.disk) def test_selem_diamond(self): + """Test diamond structuring elements""" self.strel_worker("diamond-matlab-output.npz", selem.diamond) def test_selem_ball(self): + """Test ball structuring elements""" self.strel_worker_3d("disk-matlab-output.npz", selem.ball) def test_selem_octahedron(self): + """Test octahedron structuring elements""" self.strel_worker_3d("diamond-matlab-output.npz", selem.octahedron) def test_selem_octagon(self): + """Test octagon structuring elements""" expected_mask1 = np.array([[0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], @@ -89,6 +96,7 @@ class TestSElem(): assert_equal(expected_mask2, actual_mask2) def test_selem_star(self): + """Test star structuring elements""" expected_mask1 = np.array([[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0],