Merge pull request #1313 from blink1073/suppress-test-warnings

Handle expected test warnings.
This commit is contained in:
Juan Nunez-Iglesias
2014-12-27 14:26:59 +11:00
55 changed files with 569 additions and 182 deletions
+9
View File
@@ -0,0 +1,9 @@
from skimage._shared.testing import setup_test, teardown_test
def setup():
setup_test()
def teardown():
teardown_test()
+8 -5
View File
@@ -7,6 +7,7 @@ from skimage.transform import (estimate_transform, matrix_transform,
SimilarityTransform, AffineTransform,
ProjectiveTransform, PolynomialTransform,
PiecewiseAffineTransform)
from skimage._shared._warnings import expected_warnings
SRC = np.array([
@@ -49,7 +50,7 @@ def test_estimate_transform():
def test_matrix_transform():
tform = AffineTransform(scale=(0.1, 0.5), rotation=2)
assert_equal(tform(SRC), matrix_transform(SRC, tform._matrix))
assert_equal(tform(SRC), matrix_transform(SRC, tform.params))
def test_similarity_estimation():
@@ -209,13 +210,13 @@ def test_union():
tform2 = SimilarityTransform(scale=0.1, rotation=0.9)
tform3 = SimilarityTransform(scale=0.1 ** 2, rotation=0.3 + 0.9)
tform = tform1 + tform2
assert_array_almost_equal(tform._matrix, tform3._matrix)
assert_array_almost_equal(tform.params, tform3.params)
tform1 = AffineTransform(scale=(0.1, 0.1), rotation=0.3)
tform2 = SimilarityTransform(scale=0.1, rotation=0.9)
tform3 = SimilarityTransform(scale=0.1 ** 2, rotation=0.3 + 0.9)
tform = tform1 + tform2
assert_array_almost_equal(tform._matrix, tform3._matrix)
assert_array_almost_equal(tform.params, tform3.params)
assert tform.__class__ == ProjectiveTransform
tform = AffineTransform(scale=(0.1, 0.1), rotation=0.3)
@@ -251,10 +252,12 @@ def test_invalid_input():
def test_deprecated_params_attributes():
for t in ('projective', 'affine', 'similarity'):
tform = estimate_transform(t, SRC, DST)
assert_equal(tform._matrix, tform.params)
with expected_warnings(['`_matrix`.*deprecated']):
assert_equal(tform._matrix, tform.params)
tform = estimate_transform('polynomial', SRC, DST, order=3)
assert_equal(tform._params, tform.params)
with expected_warnings(['`_params`.*deprecated']):
assert_equal(tform._params, tform.params)
if __name__ == "__main__":
@@ -3,6 +3,7 @@ from numpy.testing import assert_almost_equal, assert_equal
import skimage.transform as tf
from skimage.draw import line, circle_perimeter, ellipse_perimeter
from skimage._shared._warnings import expected_warnings
def append_desc(func, description):
@@ -67,7 +68,8 @@ def test_hough_line_peaks():
out, angles, d = tf.hough_line(img)
out, theta, dist = tf.hough_line_peaks(out, angles, d)
with expected_warnings(['`background`']):
out, theta, dist = tf.hough_line_peaks(out, angles, d)
assert_equal(len(dist), 1)
assert_almost_equal(dist[0], 80.723, 1)
@@ -79,13 +81,19 @@ def test_hough_line_peaks_dist():
img[:, 30] = True
img[:, 40] = True
hspace, angles, dists = tf.hough_line(img)
assert len(tf.hough_line_peaks(hspace, angles, dists,
min_distance=5)[0]) == 2
assert len(tf.hough_line_peaks(hspace, angles, dists,
min_distance=15)[0]) == 1
with expected_warnings(['`background`']):
assert len(tf.hough_line_peaks(hspace, angles, dists,
min_distance=5)[0]) == 2
assert len(tf.hough_line_peaks(hspace, angles, dists,
min_distance=15)[0]) == 1
def test_hough_line_peaks_angle():
with expected_warnings(['`background`']):
check_hough_line_peaks_angle()
def check_hough_line_peaks_angle():
img = np.zeros((100, 100), dtype=np.bool_)
img[:, 0] = True
img[0, :] = True
@@ -116,8 +124,9 @@ def test_hough_line_peaks_num():
img[:, 30] = True
img[:, 40] = True
hspace, angles, dists = tf.hough_line(img)
assert len(tf.hough_line_peaks(hspace, angles, dists, min_distance=0,
min_angle=0, num_peaks=1)[0]) == 1
with expected_warnings(['`background`']):
assert len(tf.hough_line_peaks(hspace, angles, dists, min_distance=0,
min_angle=0, num_peaks=1)[0]) == 1
def test_hough_circle():
+5 -2
View File
@@ -10,6 +10,7 @@ from skimage.transform import (warp, warp_coords, rotate, resize, rescale,
downscale_local_mean)
from skimage import transform as tf, data, img_as_float
from skimage.color import rgb2gray
from skimage._shared._warnings import expected_warnings
np.random.seed(0)
@@ -196,8 +197,10 @@ def test_swirl():
image = img_as_float(data.checkerboard())
swirl_params = {'radius': 80, 'rotation': 0, 'order': 2, 'mode': 'reflect'}
swirled = tf.swirl(image, strength=10, **swirl_params)
unswirled = tf.swirl(swirled, strength=-10, **swirl_params)
with expected_warnings(['Bi-quadratic.*bug']):
swirled = tf.swirl(image, strength=10, **swirl_params)
unswirled = tf.swirl(swirled, strength=-10, **swirl_params)
assert np.mean(np.abs(image - unswirled)) < 0.01