Merge pull request #590 from sciunto/python3fix

few Python3 fixes
This commit is contained in:
Tony S Yu
2013-06-20 04:40:54 -07:00
9 changed files with 18 additions and 11 deletions
+2 -1
View File
@@ -9,6 +9,7 @@ import pydoc
from StringIO import StringIO
from warnings import warn
class Reader(object):
"""A line-based string reader.
@@ -369,7 +370,7 @@ class NumpyDocString(object):
idx = self['index']
out = []
out += ['.. index:: %s' % idx.get('default','')]
for section, references in idx.iteritems():
for section, references in idx.items():
if section == 'default':
continue
out += [' :%s: %s' % (section, ', '.join(references))]
+2 -1
View File
@@ -2,6 +2,7 @@ import re, inspect, textwrap, pydoc
import sphinx
from docscrape import NumpyDocString, FunctionDoc, ClassDoc
class SphinxDocString(NumpyDocString):
def __init__(self, docstring, config={}):
self.use_plots = config.get('use_plots', False)
@@ -127,7 +128,7 @@ class SphinxDocString(NumpyDocString):
return out
out += ['.. index:: %s' % idx.get('default','')]
for section, references in idx.iteritems():
for section, references in idx.items():
if section == 'default':
continue
elif section == 'refguide':
+2 -1
View File
@@ -132,6 +132,7 @@ except ImportError:
def format_template(template, **kw):
return jinja.from_string(template, **kw)
import matplotlib
import matplotlib.cbook as cbook
matplotlib.use('Agg')
@@ -234,7 +235,7 @@ def mark_plot_labels(app, document):
the "htmlonly" (or "latexonly") node to the actual figure node
itself.
"""
for name, explicit in document.nametypes.iteritems():
for name, explicit in document.nametypes.items():
if not explicit:
continue
labelid = document.nameids[name]
+1 -2
View File
@@ -24,7 +24,6 @@ from skimage.filter import sobel
import scipy_logo
# Utility functions
# =================
@@ -49,7 +48,7 @@ def prepare_axes(ax):
plt.sca(ax)
ax.xaxis.set_visible(False)
ax.yaxis.set_visible(False)
for spine in ax.spines.itervalues():
for spine in ax.spines.values():
spine.set_visible(False)
+6 -2
View File
@@ -1,9 +1,13 @@
__all__ = ['Image', 'imread', 'imread_collection', 'imsave', 'imshow', 'show',
'push', 'pop']
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
import os
import re
import urllib2
import tempfile
from io import BytesIO
@@ -132,7 +136,7 @@ def imread(fname, as_grey=False, plugin=None, flatten=None,
if is_url(fname):
_, ext = os.path.splitext(fname)
with tempfile.NamedTemporaryFile(delete=False, suffix=ext) as f:
u = urllib2.urlopen(fname)
u = urlopen(fname)
f.write(u.read())
img = call_plugin('imread', f.name, plugin=plugin, **plugin_args)
os.remove(f.name)
+2 -1
View File
@@ -12,6 +12,7 @@ except ImportError:
import os.path
from glob import glob
plugin_store = None
plugin_provides = {}
@@ -174,7 +175,7 @@ def available(loaded=False):
"""
active_plugins = set()
for plugin_func in plugin_store.itervalues():
for plugin_func in plugin_store.values():
for plugin, func in plugin_func:
active_plugins.add(plugin)
+1 -1
View File
@@ -1 +1 @@
from viewers import ImageViewer, CollectionViewer
from .viewers import ImageViewer, CollectionViewer
+1 -1
View File
@@ -153,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 self.keyword_arguments.iteritems()])
for name, a in self.keyword_arguments.items()])
filtered = self.image_filter(*arguments, **kwargs)
self.display_filtered_image(filtered)
+1 -1
View File
@@ -81,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 segmented_data.iteritems())
for key, value in segmented_data.items())
LinearSegmentedColormap.__init__(self, name, segmented_data, **kwargs)