mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-27 19:48:43 +08:00
use items/values for python2/3 compat
This commit is contained in:
@@ -9,14 +9,6 @@ import pydoc
|
||||
from StringIO import StringIO
|
||||
from warnings import warn
|
||||
|
||||
# Python2/3 compatibility
|
||||
import sys
|
||||
PY2 = sys.version_info[0] == 2
|
||||
if PY2:
|
||||
iteritems = lambda d: d.iteritems()
|
||||
else:
|
||||
iteritems = lambda d: d.items()
|
||||
|
||||
|
||||
class Reader(object):
|
||||
"""A line-based string reader.
|
||||
@@ -378,7 +370,7 @@ class NumpyDocString(object):
|
||||
idx = self['index']
|
||||
out = []
|
||||
out += ['.. index:: %s' % idx.get('default','')]
|
||||
for section, references in iteritems(idx):
|
||||
for section, references in idx.items():
|
||||
if section == 'default':
|
||||
continue
|
||||
out += [' :%s: %s' % (section, ', '.join(references))]
|
||||
|
||||
@@ -2,14 +2,6 @@ import re, inspect, textwrap, pydoc
|
||||
import sphinx
|
||||
from docscrape import NumpyDocString, FunctionDoc, ClassDoc
|
||||
|
||||
# Python2/3 compatibility
|
||||
import sys
|
||||
PY2 = sys.version_info[0] == 2
|
||||
if PY2:
|
||||
iteritems = lambda d: d.iteritems()
|
||||
else:
|
||||
iteritems = lambda d: d.items()
|
||||
|
||||
|
||||
class SphinxDocString(NumpyDocString):
|
||||
def __init__(self, docstring, config={}):
|
||||
@@ -136,7 +128,7 @@ class SphinxDocString(NumpyDocString):
|
||||
return out
|
||||
|
||||
out += ['.. index:: %s' % idx.get('default','')]
|
||||
for section, references in iteritems(idx):
|
||||
for section, references in idx.items():
|
||||
if section == 'default':
|
||||
continue
|
||||
elif section == 'refguide':
|
||||
|
||||
@@ -132,13 +132,6 @@ except ImportError:
|
||||
def format_template(template, **kw):
|
||||
return jinja.from_string(template, **kw)
|
||||
|
||||
# Python2/3 compatibility
|
||||
import sys
|
||||
PY2 = sys.version_info[0] == 2
|
||||
if PY2:
|
||||
iteritems = lambda d: d.iteritems()
|
||||
else:
|
||||
iteritems = lambda d: d.items()
|
||||
|
||||
import matplotlib
|
||||
import matplotlib.cbook as cbook
|
||||
@@ -242,7 +235,7 @@ def mark_plot_labels(app, document):
|
||||
the "htmlonly" (or "latexonly") node to the actual figure node
|
||||
itself.
|
||||
"""
|
||||
for name, explicit in iteritems(document.nametypes):
|
||||
for name, explicit in document.nametypes.items():
|
||||
if not explicit:
|
||||
continue
|
||||
labelid = document.nameids[name]
|
||||
|
||||
@@ -24,13 +24,6 @@ from skimage.filter import sobel
|
||||
|
||||
import scipy_logo
|
||||
|
||||
# Python2/3 compatibility
|
||||
PY2 = sys.version_info[0] == 2
|
||||
if PY2:
|
||||
itervalues = lambda d: d.itervalues()
|
||||
else:
|
||||
itervalues = lambda d: d.values()
|
||||
|
||||
# Utility functions
|
||||
# =================
|
||||
|
||||
@@ -55,7 +48,7 @@ def prepare_axes(ax):
|
||||
plt.sca(ax)
|
||||
ax.xaxis.set_visible(False)
|
||||
ax.yaxis.set_visible(False)
|
||||
for spine in itervalues(ax.spines):
|
||||
for spine in ax.spines.values():
|
||||
spine.set_visible(False)
|
||||
|
||||
|
||||
|
||||
@@ -12,13 +12,6 @@ except ImportError:
|
||||
import os.path
|
||||
from glob import glob
|
||||
|
||||
# Python2/3 compatibility
|
||||
import sys
|
||||
PY2 = sys.version_info[0] == 2
|
||||
if PY2:
|
||||
itervalues = lambda d: d.itervalues()
|
||||
else:
|
||||
itervalues = lambda d: d.values()
|
||||
|
||||
plugin_store = None
|
||||
|
||||
@@ -182,7 +175,7 @@ def available(loaded=False):
|
||||
|
||||
"""
|
||||
active_plugins = set()
|
||||
for plugin_func in itervalues(plugin_store):
|
||||
for plugin_func in plugin_store.values():
|
||||
for plugin, func in plugin_func:
|
||||
active_plugins.add(plugin)
|
||||
|
||||
|
||||
@@ -7,15 +7,6 @@ from ..qt.QtCore import Qt
|
||||
from ..utils import RequiredAttr, init_qtapp
|
||||
|
||||
|
||||
# Python2/3 compatibility
|
||||
import sys
|
||||
PY2 = sys.version_info[0] == 2
|
||||
if PY2:
|
||||
iteritems = lambda d: d.iteritems()
|
||||
else:
|
||||
iteritems = lambda d: d.items()
|
||||
|
||||
|
||||
class Plugin(QtGui.QDialog):
|
||||
"""Base class for plugins that interact with an ImageViewer.
|
||||
|
||||
@@ -162,7 +153,7 @@ class Plugin(QtGui.QDialog):
|
||||
return
|
||||
arguments = [self._get_value(a) for a in self.arguments]
|
||||
kwargs = dict([(name, self._get_value(a))
|
||||
for name, a in iteritems(self.keyword_arguments)])
|
||||
for name, a in self.keyword_arguments.items()])
|
||||
filtered = self.image_filter(*arguments, **kwargs)
|
||||
self.display_filtered_image(filtered)
|
||||
|
||||
|
||||
@@ -21,13 +21,6 @@ except ImportError:
|
||||
|
||||
from ..qt import QtGui
|
||||
|
||||
# Python2/3 compatibility
|
||||
import sys
|
||||
PY2 = sys.version_info[0] == 2
|
||||
if PY2:
|
||||
iteritems = lambda d: d.iteritems()
|
||||
else:
|
||||
iteritems = lambda d: d.items()
|
||||
|
||||
__all__ = ['init_qtapp', 'start_qtapp', 'RequiredAttr', 'figimage',
|
||||
'LinearColormap', 'ClearColormap', 'FigureCanvas', 'new_plot']
|
||||
@@ -88,7 +81,7 @@ class LinearColormap(LinearSegmentedColormap):
|
||||
"""
|
||||
def __init__(self, name, segmented_data, **kwargs):
|
||||
segmented_data = dict((key, [(x, y, y) for x, y in value])
|
||||
for key, value in iteritems(segmented_data))
|
||||
for key, value in segmented_data.items())
|
||||
LinearSegmentedColormap.__init__(self, name, segmented_data, **kwargs)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user