mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-24 13:20:43 +08:00
Correctly check for string type.
This commit is contained in:
+3
-2
@@ -15,6 +15,7 @@ import numpy as np
|
||||
|
||||
from skimage.io._plugins import call as call_plugin
|
||||
from skimage.color import rgb2grey
|
||||
from skimage._shared import six
|
||||
|
||||
|
||||
# Shared image queue
|
||||
@@ -25,7 +26,7 @@ URL_REGEX = re.compile(r'http://|https://|ftp://|file://|file:\\')
|
||||
|
||||
def is_url(filename):
|
||||
"""Return True if string is an http or ftp path."""
|
||||
return (isinstance(filename, basestring) and
|
||||
return (isinstance(filename, six.string_types) and
|
||||
URL_REGEX.match(filename) is not None)
|
||||
|
||||
|
||||
@@ -220,7 +221,7 @@ def imshow(arr, plugin=None, **plugin_args):
|
||||
Passed to the given plugin.
|
||||
|
||||
"""
|
||||
if isinstance(arr, basestring):
|
||||
if isinstance(arr, six.string_types):
|
||||
arr = call_plugin('imread', arr, plugin=plugin)
|
||||
return call_plugin('imshow', arr, plugin=plugin, **plugin_args)
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ from copy import copy
|
||||
|
||||
import numpy as np
|
||||
from ._io import imread
|
||||
from .._shared import six
|
||||
|
||||
|
||||
def concatenate_images(ic):
|
||||
@@ -296,7 +297,7 @@ class ImageCollection(object):
|
||||
"""
|
||||
def __init__(self, load_pattern, conserve_memory=True, load_func=None):
|
||||
"""Load and manage a collection of images."""
|
||||
if isinstance(load_pattern, basestring):
|
||||
if isinstance(load_pattern, six.string_types):
|
||||
load_pattern = load_pattern.split(':')
|
||||
self._files = []
|
||||
for pattern in load_pattern:
|
||||
|
||||
@@ -12,6 +12,7 @@ from skimage import data_dir
|
||||
from skimage.io import ImageCollection, MultiImage
|
||||
from skimage.io.collection import alphanumeric_key
|
||||
from skimage.io import Image as ioImage
|
||||
from skimage._shared import six
|
||||
|
||||
|
||||
try:
|
||||
@@ -21,8 +22,6 @@ except ImportError:
|
||||
else:
|
||||
PIL_available = True
|
||||
|
||||
if sys.version_info[0] > 2:
|
||||
basestring = str
|
||||
|
||||
class TestAlphanumericKey():
|
||||
def setUp(self):
|
||||
@@ -129,7 +128,7 @@ class TestMultiImage():
|
||||
|
||||
@skipif(not PIL_available)
|
||||
def test_files_property(self):
|
||||
assert isinstance(self.img.filename, basestring)
|
||||
assert isinstance(self.img.filename, six.string_types)
|
||||
|
||||
def set_filename(f):
|
||||
self.img.filename = f
|
||||
|
||||
@@ -3,6 +3,7 @@ from warnings import warn
|
||||
from skimage.util.dtype import dtype_range
|
||||
from .base import Plugin
|
||||
from ..utils import ClearColormap, update_axes_image
|
||||
from skimage._shared import six
|
||||
|
||||
|
||||
__all__ = ['OverlayPlugin']
|
||||
@@ -77,7 +78,8 @@ class OverlayPlugin(Plugin):
|
||||
@color.setter
|
||||
def color(self, index):
|
||||
# Update colormap whenever color is changed.
|
||||
if isinstance(index, basestring) and index not in self.color_names:
|
||||
if isinstance(index, six.string_types) and \
|
||||
index not in self.color_names:
|
||||
raise ValueError("%s not defined in OverlayPlugin.colors" % index)
|
||||
else:
|
||||
name = self.color_names[index]
|
||||
|
||||
Reference in New Issue
Block a user