Handle more warnings

Punt on the issue of warnings with the minimum build

Handle warnings in measure pkg

Fix the rank filter test by forcing a random seed in the function

Compare as boolean in imread test

Import loadmat in test_setup to avoid warning

Use a setup method for imread plugin test

Revoke unintended changes

Fix indentation to appease jni

More indentation fixes

Fix unintentional comment out
This commit is contained in:
Steven Silvester
2014-12-22 06:36:59 -06:00
parent 6db92d387b
commit 782ba46a4c
14 changed files with 29 additions and 23 deletions
View File
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
View File
Regular → Executable
+1 -1
View File
@@ -149,7 +149,7 @@ if __name__ == "__main__":
configuration=configuration,
install_requires=[
"six>=%s" % '.'.join(str(d) for d in DEPENDENCIES['six'])
"six>=%s" % DEPENDENCIES['six']
],
packages=setuptools.find_packages(exclude=['doc']),
include_package_data=True,
+5 -3
View File
@@ -179,12 +179,14 @@ def mono_check(plugin, fmt='png'):
def setup_test():
warnings.simplefilter('error')
with all_warnings():
warnings.simplefilter('error')
with all_warnings():
from scipy import signal, ndimage, special, optimize, linalg
from scipy.io import loadmat
from skimage import filter, viewer, data
data.moon()
if os.environ.get('TRAVIS_PYTHON_VERSION', None) == '2.7':
warnings.simplefilter('default')
if __name__ == '__main__':
color_check('pil')
+14 -14
View File
@@ -13,12 +13,12 @@ np.random.seed(0)
def test_all():
with all_warnings(): # precision loss
check_all()
with all_warnings(): # precision loss
check_all()
def check_all():
np.random.seed(0)
image = np.random.rand(25, 25)
selem = morphology.disk(1)
refs = np.load(os.path.join(skimage.data_dir, "rank_filter_tests.npz"))
@@ -159,7 +159,7 @@ def test_bitdepth():
for i in range(5):
image = np.ones((100, 100), dtype=np.uint16) * 255 * 2 ** i
with all_warnings(): # bit depth
rank.mean_percentile(image=image, selem=elem, mask=mask,
rank.mean_percentile(image=image, selem=elem, mask=mask,
out=out, shift_x=0, shift_y=0, p0=.1, p1=.9)
@@ -270,7 +270,7 @@ def test_compare_ubyte_vs_float():
func = getattr(rank, method)
out_u = func(image_uint, disk(3))
with all_warnings(): # precision loss
out_f = func(image_float, disk(3))
out_f = func(image_float, disk(3))
assert_equal(out_u, out_f)
@@ -283,9 +283,9 @@ def test_compare_8bit_unsigned_vs_signed():
image[image > 127] = 0
image_s = image.astype(np.int8)
with all_warnings(): # precision loss
image_u = img_as_ubyte(image_s)
image_u = img_as_ubyte(image_s)
assert_equal(image_u, img_as_ubyte(image_s))
assert_equal(image_u, img_as_ubyte(image_s))
methods = ['autolevel', 'bottomhat', 'equalize', 'gradient', 'maximum',
'mean', 'subtract_mean', 'median', 'minimum', 'modal',
@@ -295,8 +295,8 @@ def test_compare_8bit_unsigned_vs_signed():
func = getattr(rank, method)
with all_warnings(): # sign loss
out_u = func(image_u, disk(3))
out_s = func(image_s, disk(3))
out_u = func(image_u, disk(3))
out_s = func(image_s, disk(3))
assert_equal(out_u, out_s)
@@ -487,11 +487,11 @@ def test_entropy():
data = np.tile(
np.reshape(np.arange(4096), (64, 64)), (2, 2)).astype(np.uint16)
with all_warnings(): # bitdepth
assert(np.max(rank.entropy(data, selem)) == 12)
assert(np.max(rank.entropy(data, selem)) == 12)
# make sure output is of dtype double
with all_warnings(): # bitdepth
out = rank.entropy(data, np.ones((16, 16), dtype=np.uint8))
out = rank.entropy(data, np.ones((16, 16), dtype=np.uint8))
assert out.dtype == np.double
@@ -523,9 +523,9 @@ def test_16bit():
value = 2 ** bitdepth - 1
image[10, 10] = value
with all_warnings(): # bitdepth
assert rank.minimum(image, selem)[10, 10] == 0
assert rank.maximum(image, selem)[10, 10] == value
assert rank.mean(image, selem)[10, 10] == int(value / selem.size)
assert rank.minimum(image, selem)[10, 10] == 0
assert rank.maximum(image, selem)[10, 10] == value
assert rank.mean(image, selem)[10, 10] == int(value / selem.size)
def test_bilateral():
+1 -2
View File
@@ -48,8 +48,7 @@ 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]
pass
im.getdata()[0]
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))
+6 -3
View File
@@ -11,13 +11,16 @@ import skimage.io as sio
try:
import imread as _imread
use_plugin('imread')
except ImportError:
imread_available = False
else:
imread_available = True
np.random.seed(0)
def setup():
if imread_available:
np.random.seed(0)
use_plugin('imread')
def teardown():
@@ -54,7 +57,7 @@ def test_bilevel():
expected[::2] = 1
img = imread(os.path.join(data_dir, 'checker_bilevel.png'))
assert_array_equal(img, expected)
assert_array_equal(img.astype(bool), expected)
class TestSave:
Regular → Executable
View File
View File
+2
View File
@@ -0,0 +1,2 @@
from skimage._shared.testing import setup_test
setup_test()
Regular → Executable
View File