Fix handling of multiple warnings and update tests

Fix handling of multiple warnings

Update all test __init__ files

Update segmentation pkg

Update the color pkg

Update the exposure pkg

Update the filters pkg

Update the io pkg

Update the measure pkg

Update morphology package

Restructure test setup function

Add expected_warnings to __all__

Update restoration pkg.

Remove explicit filter check since it is done elsewhere

Fix the image test helpers

Update the transform pkg

Fix util pkg

Update viewer pkg
This commit is contained in:
Steven Silvester
2014-12-23 16:51:06 -06:00
parent 01ca1d17c8
commit c0a0490eed
40 changed files with 288 additions and 175 deletions
+11 -13
View File
@@ -9,7 +9,7 @@ from skimage import (
data, io, img_as_uint, img_as_float, img_as_int, img_as_ubyte)
from numpy import testing
import numpy as np
from skimage._shared.utils import all_warnings
from skimage._shared._warnings import expected_warnings
import warnings
@@ -117,24 +117,24 @@ def color_check(plugin, fmt='png'):
testing.assert_allclose(img2.astype(np.uint8), r2)
img3 = img_as_float(img)
with all_warnings(): # precision loss
with expected_warnings(['precision loss']):
r3 = roundtrip(img3, plugin, fmt)
testing.assert_allclose(r3, img)
with all_warnings(): # precision loss
with expected_warnings(['precision loss']):
img4 = img_as_int(img)
if fmt.lower() in (('tif', 'tiff')):
img4 -= 100
with all_warnings(): # sign loss
with expected_warnings(['sign loss']):
r4 = roundtrip(img4, plugin, fmt)
testing.assert_allclose(r4, img4)
else:
with all_warnings(): # sign loss
with expected_warnings(['sign loss']):
r4 = roundtrip(img4, plugin, fmt)
testing.assert_allclose(r4, img_as_ubyte(img4))
img5 = img_as_uint(img)
with all_warnings(): # precision loss
with expected_warnings(['precision loss']):
r5 = roundtrip(img5, plugin, fmt)
testing.assert_allclose(r5, img)
@@ -154,22 +154,22 @@ def mono_check(plugin, fmt='png'):
testing.assert_allclose(img2.astype(np.uint8), r2)
img3 = img_as_float(img)
with all_warnings(): # precision loss
with expected_warnings(['precision loss']):
r3 = roundtrip(img3, plugin, fmt)
if r3.dtype.kind == 'f':
testing.assert_allclose(img3, r3)
else:
testing.assert_allclose(r3, img_as_uint(img))
with all_warnings(): # precision loss
with expected_warnings(['precision loss']):
img4 = img_as_int(img)
if fmt.lower() in (('tif', 'tiff')):
img4 -= 100
with all_warnings(): # sign loss
with expected_warnings(['sign loss']):
r4 = roundtrip(img4, plugin, fmt)
testing.assert_allclose(r4, img4)
else:
with all_warnings(): # sign loss
with expected_warnings(['sign loss']):
r4 = roundtrip(img4, plugin, fmt)
testing.assert_allclose(r4, img_as_uint(img4))
@@ -188,9 +188,7 @@ def setup_test():
warnings.simplefilter('default')
from scipy import signal, ndimage, special, optimize, linalg
from scipy.io import loadmat
from skimage import filter, viewer, data
# trigger PIL warnings
data.moon()
from skimage import viewer, filter
np.random.seed(0)
warnings.simplefilter('error')