Handle more warnings and reset io plugins as needed

Reset plugins prior to running collections test

Handle warnings in morphology pkg

Add __init__ for morpohology tests

Handle warnings for novice pkg

Handle warnings for restoration pkg

Handle warnings for segmentation pkg

Handle warnings for _shared pkg

Handle warnings for transform pkg

Handle warnings for util pkg

Handle warnings in viewer module
This commit is contained in:
Steven Silvester
2014-12-23 16:48:16 -06:00
parent 9e8f91930e
commit 0debedd82c
21 changed files with 161 additions and 75 deletions
+2
View File
@@ -0,0 +1,2 @@
import warnings
warnings.simplefilter('error')
+8 -5
View File
@@ -7,6 +7,7 @@ from skimage.transform import (estimate_transform, matrix_transform,
SimilarityTransform, AffineTransform,
ProjectiveTransform, PolynomialTransform,
PiecewiseAffineTransform)
from skimage._shared.utils import all_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 all_warnings(): # _matrix is deprecated
assert_equal(tform._matrix, tform.params)
tform = estimate_transform('polynomial', SRC, DST, order=3)
assert_equal(tform._params, tform.params)
with all_warnings(): # _params is 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.utils import all_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 all_warnings(): # _ccomp deprecation
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 all_warnings(): # _ccomp deprecation
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 all_warnings(): # _ccomp deprecation
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 all_warnings(): # _ccomp deprecation
assert len(tf.hough_line_peaks(hspace, angles, dists, min_distance=0,
min_angle=0, num_peaks=1)[0]) == 1
def test_hough_circle():