diff --git a/skimage/_shared/utils.py b/skimage/_shared/utils.py index 43fda35d..7be979bc 100644 --- a/skimage/_shared/utils.py +++ b/skimage/_shared/utils.py @@ -163,3 +163,4 @@ def assert_nD(array, ndim, arg_name='image'): ndim = [ndim] if not array.ndim in ndim: raise ValueError(msg % (arg_name, '-or-'.join([str(n) for n in ndim]))) + diff --git a/skimage/color/tests/__init__.py b/skimage/color/tests/__init__.py new file mode 100644 index 00000000..0922ce59 --- /dev/null +++ b/skimage/color/tests/__init__.py @@ -0,0 +1,2 @@ +import warnings +warnings.simplefilter('error') diff --git a/skimage/color/tests/test_adapt_rgb.py b/skimage/color/tests/test_adapt_rgb.py index 2f3060c5..f4da0e58 100644 --- a/skimage/color/tests/test_adapt_rgb.py +++ b/skimage/color/tests/test_adapt_rgb.py @@ -3,54 +3,55 @@ from functools import partial import numpy as np from skimage import img_as_float, img_as_uint -from skimage import color, data, filter +from skimage import color, data, filters from skimage.color.adapt_rgb import adapt_rgb, each_channel, hsv_value - +from skimage._shared.utils import all_warnings # Down-sample image for quicker testing. COLOR_IMAGE = data.astronaut()[::5, ::5] GRAY_IMAGE = data.camera()[::5, ::5] SIGMA = 3 -smooth = partial(filter.gaussian_filter, sigma=SIGMA) +smooth = partial(filters.gaussian_filter, sigma=SIGMA) assert_allclose = partial(np.testing.assert_allclose, atol=1e-8) @adapt_rgb(each_channel) def edges_each(image): - return filter.sobel(image) + return filters.sobel(image) @adapt_rgb(each_channel) def smooth_each(image, sigma): - return filter.gaussian_filter(image, sigma) + return filters.gaussian_filter(image, sigma) @adapt_rgb(hsv_value) def edges_hsv(image): - return filter.sobel(image) + return filters.sobel(image) @adapt_rgb(hsv_value) def smooth_hsv(image, sigma): - return filter.gaussian_filter(image, sigma) + return filters.gaussian_filter(image, sigma) @adapt_rgb(hsv_value) def edges_hsv_uint(image): - return img_as_uint(filter.sobel(image)) + with all_warnings(): # precision loss + return img_as_uint(filters.sobel(image)) def test_gray_scale_image(): # We don't need to test both `hsv_value` and `each_channel` since # `adapt_rgb` is handling gray-scale inputs. - assert_allclose(edges_each(GRAY_IMAGE), filter.sobel(GRAY_IMAGE)) + assert_allclose(edges_each(GRAY_IMAGE), filters.sobel(GRAY_IMAGE)) def test_each_channel(): filtered = edges_each(COLOR_IMAGE) for i, channel in enumerate(np.rollaxis(filtered, axis=-1)): - expected = img_as_float(filter.sobel(COLOR_IMAGE[:, :, i])) + expected = img_as_float(filters.sobel(COLOR_IMAGE[:, :, i])) assert_allclose(channel, expected) @@ -63,7 +64,7 @@ def test_each_channel_with_filter_argument(): def test_hsv_value(): filtered = edges_hsv(COLOR_IMAGE) value = color.rgb2hsv(COLOR_IMAGE)[:, :, 2] - assert_allclose(color.rgb2hsv(filtered)[:, :, 2], filter.sobel(value)) + assert_allclose(color.rgb2hsv(filtered)[:, :, 2], filters.sobel(value)) def test_hsv_value_with_filter_argument(): @@ -80,4 +81,4 @@ def test_hsv_value_with_non_float_output(): filtered_value = color.rgb2hsv(filtered)[:, :, 2] value = color.rgb2hsv(COLOR_IMAGE)[:, :, 2] # Reduce tolerance because dtype conversion. - assert_allclose(filtered_value, filter.sobel(value), rtol=1e-5, atol=1e-5) + assert_allclose(filtered_value, filters.sobel(value), rtol=1e-5, atol=1e-5) diff --git a/skimage/color/tests/test_colorconv.py b/skimage/color/tests/test_colorconv.py index cf960f4e..c61a67b2 100644 --- a/skimage/color/tests/test_colorconv.py +++ b/skimage/color/tests/test_colorconv.py @@ -39,7 +39,8 @@ from skimage.color import (rgb2hsv, hsv2rgb, guess_spatial_dimensions ) -from skimage import data_dir, data +from skimage import data_dir +from skimage._shared.utils import all_warnings import colorsys @@ -156,7 +157,9 @@ class TestColorconv(TestCase): # RGB<->HED roundtrip with ubyte image def test_hed_rgb_roundtrip(self): img_rgb = img_as_ubyte(self.img_rgb) - assert_equal(img_as_ubyte(hed2rgb(rgb2hed(img_rgb))), img_rgb) + with all_warnings(): # precision loss + new = img_as_ubyte(hed2rgb(rgb2hed(img_rgb))) + assert_equal(new, img_rgb) # RGB<->HED roundtrip with float image def test_hed_rgb_float_roundtrip(self): diff --git a/skimage/data/tests/__init__.py b/skimage/data/tests/__init__.py new file mode 100644 index 00000000..0922ce59 --- /dev/null +++ b/skimage/data/tests/__init__.py @@ -0,0 +1,2 @@ +import warnings +warnings.simplefilter('error') diff --git a/skimage/draw/tests/__init__.py b/skimage/draw/tests/__init__.py new file mode 100644 index 00000000..0922ce59 --- /dev/null +++ b/skimage/draw/tests/__init__.py @@ -0,0 +1,2 @@ +import warnings +warnings.simplefilter('error') diff --git a/skimage/exposure/tests/__init__.py b/skimage/exposure/tests/__init__.py new file mode 100644 index 00000000..0922ce59 --- /dev/null +++ b/skimage/exposure/tests/__init__.py @@ -0,0 +1,2 @@ +import warnings +warnings.simplefilter('error') diff --git a/skimage/exposure/tests/test_exposure.py b/skimage/exposure/tests/test_exposure.py index ec9840ee..bb047195 100644 --- a/skimage/exposure/tests/test_exposure.py +++ b/skimage/exposure/tests/test_exposure.py @@ -11,6 +11,7 @@ from skimage import exposure from skimage.exposure.exposure import intensity_range from skimage.color import rgb2gray from skimage.util.dtype import dtype_range +from skimage._shared.utils import all_warnings # Test integer histograms @@ -52,7 +53,8 @@ def test_equalize_uint8_approx(): def test_equalize_ubyte(): - img = skimage.img_as_ubyte(test_img) + with all_warnings(): # precision loss + img = skimage.img_as_ubyte(test_img) img_eq = exposure.equalize_hist(img) cdf, bin_edges = exposure.cumulative_distribution(img_eq) @@ -209,8 +211,9 @@ def test_adapthist_grayscale(): img = skimage.img_as_float(data.astronaut()) img = rgb2gray(img) img = np.dstack((img, img, img)) - adapted = exposure.equalize_adapthist(img, 10, 9, clip_limit=0.01, - nbins=128) + with all_warnings(): # precision loss + adapted = exposure.equalize_adapthist(img, 10, 9, clip_limit=0.01, + nbins=128) assert_almost_equal = np.testing.assert_almost_equal assert img.shape == adapted.shape assert_almost_equal(peak_snr(img, adapted), 97.6876, 3) @@ -226,7 +229,8 @@ def test_adapthist_color(): warnings.simplefilter('always') hist, bin_centers = exposure.histogram(img) assert len(w) > 0 - adapted = exposure.equalize_adapthist(img, clip_limit=0.01) + with all_warnings(): # precision loss + adapted = exposure.equalize_adapthist(img, clip_limit=0.01) assert_almost_equal = np.testing.assert_almost_equal assert adapted.min() == 0 @@ -244,7 +248,8 @@ def test_adapthist_alpha(): img = skimage.img_as_float(data.astronaut()) alpha = np.ones((img.shape[0], img.shape[1]), dtype=float) img = np.dstack((img, alpha)) - adapted = exposure.equalize_adapthist(img) + with all_warnings(): # precision loss + adapted = exposure.equalize_adapthist(img) assert adapted.shape != img.shape img = img[:, :, :3] full_scale = skimage.exposure.rescale_intensity(img) diff --git a/skimage/io/_plugins/pil_plugin.py b/skimage/io/_plugins/pil_plugin.py index 5018be49..1b0d9efd 100644 --- a/skimage/io/_plugins/pil_plugin.py +++ b/skimage/io/_plugins/pil_plugin.py @@ -39,6 +39,7 @@ def imread(fname, dtype=None, img_num=None, **kwargs): .. [2] http://pillow.readthedocs.org/en/latest/handbook/image-file-formats.html """ + print('imread', fname) if hasattr(fname, 'lower') and dtype is None: kwargs.setdefault('key', img_num) if fname.lower().endswith(('.tiff', '.tif')): @@ -47,7 +48,8 @@ def imread(fname, dtype=None, img_num=None, **kwargs): im = Image.open(fname) try: # this will raise an IOError if the file is not readable - im.getdata()[0] + #im.getdata()[0] + pass except IOError: site = "http://pillow.readthedocs.org/en/latest/installation.html#external-libraries" raise ValueError('Could not load "%s"\nPlease see documentation at: %s' % (fname, site))