More doctest and pil_plugin fixes

Fix Python2 imread in pil_plugin.

Load from data

Use all_warnings when importing the other packages

More fixes for regionprops doctest
This commit is contained in:
Steven Silvester
2014-12-21 19:41:16 -06:00
parent 4680f30466
commit 6db92d387b
3 changed files with 13 additions and 6 deletions
+4 -2
View File
@@ -179,9 +179,11 @@ def mono_check(plugin, fmt='png'):
def setup_test():
from scipy import signal, ndimage, special, optimize, linalg
from skimage import filter, viewer
warnings.simplefilter('error')
with all_warnings():
from scipy import signal, ndimage, special, optimize, linalg
from skimage import filter, viewer, data
data.moon()
if __name__ == '__main__':
+5 -2
View File
@@ -180,7 +180,10 @@ def ndarray_to_pil(arr, format_str=None):
if arr.ndim == 2:
im = Image.new(mode_base, arr.T.shape)
im.frombytes(arr.tobytes(), 'raw', mode)
try:
im.frombytes(arr.tobytes(), 'raw', mode)
except AttributeError:
im.frombytes(arr.tostring(), 'raw', mode)
else:
try:
@@ -188,7 +191,7 @@ def ndarray_to_pil(arr, format_str=None):
arr.tobytes())
except AttributeError:
im = Image.frombytes(mode, (arr.shape[1], arr.shape[0]),
arr.tobytes())
arr.tostring())
return im
+4 -2
View File
@@ -475,9 +475,11 @@ def regionprops(label_image, intensity_image=None, cache=True):
>>> img = util.img_as_ubyte(data.coins()) > 110
>>> label_img = label(img) # doctest: +SKIP
>>> props = regionprops(label_img) # doctest: +SKIP
>>> props[0].centroid # doctest: +SKIP centroid of first labeled object
>>> # centroid of first labeled object
>>> props[0].centroid # doctest: +SKIP
(22.729879860483141, 81.912285234465827)
>>> props[0]['centroid'] # doctest: +SKIP centroid of first labeled object
>>> # centroid of first labeled object
>>> props[0]['centroid'] # doctest: +SKIP
(22.729879860483141, 81.912285234465827)
"""