Skip to content

Commit 40621da

Browse files
committed
Merge pull request #152 from Eric89GXL/py3k
MRG: Py3k support
2 parents e704ac3 + a079c22 commit 40621da

File tree

5 files changed

+31
-24
lines changed

5 files changed

+31
-24
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ env:
1515
before_install:
1616
- wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
1717
- chmod +x miniconda.sh
18-
- ./miniconda.sh -b
18+
- ./miniconda.sh -b -p /home/travis/miniconda
1919
- export PATH=/home/travis/miniconda/bin:$PATH
2020
- conda update --yes conda
2121

2222
install:
2323
- conda create -n testenv --yes pip python=$PYTHON
2424
- source activate testenv
2525
# Pillow (or PIL/imaging) is necessary for scipy.misc.imsave to exist
26-
- conda install --yes --quiet ipython==1.1.0 numpy scipy mayavi matplotlib nose imaging
26+
- conda install --yes --quiet numpy scipy mayavi matplotlib nose imaging
2727
- if [ "${DEPS}" == "full" ]; then
2828
travis_retry sudo apt-get update -qq;
2929
travis_retry sudo apt-get install mencoder;

examples/plot_meg_inverse_solution.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
"""
2525
brain = Brain(subject_id, hemi, surface, size=(800, 400))
2626

27+
"""
28+
label for time annotation in milliseconds
29+
"""
30+
31+
32+
def time_label(t):
33+
return 'time=%0.2f ms' % (t * 1e3)
34+
2735
"""
2836
read MNE dSPM inverse solution
2937
"""
@@ -49,11 +57,6 @@
4957
"""
5058
colormap = 'hot'
5159

52-
"""
53-
label for time annotation in milliseconds
54-
"""
55-
time_label = lambda t: 'time=%0.2f ms' % (t * 1e3)
56-
5760
brain.add_data(data, colormap=colormap, vertices=vertices,
5861
smoothing_steps=10, time=time, time_label=time_label,
5962
hemi=hemi)

setup.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
# Martin Luessi
77
# Eric Larson
88

9+
import os
10+
from setuptools import setup
11+
912
descr = """PySurfer: cortical surface visualization using Python."""
1013

11-
import os
1214
# deal with MPL sandbox violations during easy_install
1315
os.environ['MPLCONFIGDIR'] = '.'
1416

@@ -32,10 +34,9 @@
3234
DOWNLOAD_URL = 'https://github.com/nipy/PySurfer'
3335
VERSION = version
3436

35-
def check_dependencies():
3637

37-
needed_deps = ["IPython",
38-
"numpy", "scipy", "matplotlib",
38+
def check_dependencies():
39+
needed_deps = ["numpy", "scipy", "matplotlib",
3940
"mayavi",
4041
]
4142
missing_deps = []
@@ -50,8 +51,6 @@ def check_dependencies():
5051
raise ImportError("Missing dependencies: %s" % missing)
5152

5253

53-
from setuptools import setup
54-
5554
if __name__ == "__main__":
5655
if os.path.exists('MANIFEST'):
5756
os.remove('MANIFEST')
@@ -64,7 +63,6 @@ def check_dependencies():
6463
'clean'))):
6564
check_dependencies()
6665

67-
6866
setup(name=DISTNAME,
6967
maintainer=MAINTAINER,
7068
include_package_data=True,
@@ -79,6 +77,9 @@ def check_dependencies():
7977
classifiers=['Intended Audience :: Science/Research',
8078
'Intended Audience :: Developers',
8179
'Programming Language :: Python :: 2.7',
80+
'Programming Language :: Python :: 3.3',
81+
'Programming Language :: Python :: 3.4',
82+
'Programming Language :: Python :: 3.5',
8283
'License :: OSI Approved',
8384
'Programming Language :: Python',
8485
'Topic :: Software Development',

surfer/io.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ def project_volume_data(filepath, hemi, reg_file=None, subject_id=None,
176176
cmd = ['bash', '-c', 'source {} && env'.format(
177177
os.path.join(env['FREESURFER_HOME'], 'FreeSurferEnv.sh'))]
178178
envout = check_output(cmd)
179-
env = dict(line.split('=', 1) for line in envout.split('\n')
179+
env = dict(line.split('=', 1)
180+
for line in envout.decode('utf-8').split('\n')
180181
if '=' in line)
181182

182183
# Set the basic commands
@@ -199,7 +200,7 @@ def project_volume_data(filepath, hemi, reg_file=None, subject_id=None,
199200
proj_flag += "-"
200201
proj_flag += projsum
201202
if hasattr(projarg, "__iter__"):
202-
proj_arg = map(str, projarg)
203+
proj_arg = list(map(str, projarg))
203204
else:
204205
proj_arg = [str(projarg)]
205206
cmd_list.extend([proj_flag] + proj_arg)

surfer/viz.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ def make_montage(filename, fnames, orientation='h', colorbar=None,
8282
# dimension-dependent-attributeerror-in-pil-fromarray-function
8383
fnames = [f if isinstance(f, string_types) else f.copy() for f in fnames]
8484
if isinstance(fnames[0], string_types):
85-
images = map(Image.open, fnames)
85+
images = list(map(Image.open, fnames))
8686
else:
87-
images = map(Image.fromarray, fnames)
87+
images = list(map(Image.fromarray, fnames))
8888
# get bounding box for cropping
8989
boxes = []
9090
for ix, im in enumerate(images):
@@ -566,7 +566,7 @@ def _get_one_brain(self, d, name):
566566
'or brain.brains.' % name)
567567
if isinstance(d, dict):
568568
out = dict()
569-
for key, value in d.iteritems():
569+
for key, value in d.items():
570570
out[key] = value[0]
571571
else:
572572
out = d[0]
@@ -595,7 +595,7 @@ def contour(self):
595595
@property
596596
def annot(self):
597597
"""Wrap to annot"""
598-
return self._get_one_brain(self.annot_list, 'contour')
598+
return self._get_one_brain(self.annot_list, 'annot')
599599

600600
@property
601601
def texts(self):
@@ -879,9 +879,11 @@ def add_data(self, array, min=None, max=None, thresh=None,
879879
if not self.n_times == len(time):
880880
raise ValueError('time is not the same length as '
881881
'array.shape[1]')
882-
if isinstance(time_label, basestring):
882+
if isinstance(time_label, string_types):
883883
time_label_fmt = time_label
884-
time_label = lambda x: time_label_fmt % x
884+
885+
def time_label(x):
886+
return time_label_fmt % x
885887
data["time_label"] = time_label
886888
data["time"] = time
887889
data["time_idx"] = 0
@@ -1374,7 +1376,7 @@ def add_contour_overlay(self, source, min=None, max=None,
13741376
scalar_data = _prepare_data(scalar_data)
13751377

13761378
# Maybe get rid of an old overlay
1377-
if hasattr(self, "contour") and remove_existing:
1379+
if remove_existing:
13781380
for c in self.contour_list:
13791381
c['surface'].remove()
13801382
if c['colorbar'] is not None:
@@ -2234,7 +2236,7 @@ def animate(self, views, n_steps=180., fname=None, use_cache=False,
22342236
Column index of the brain to use
22352237
"""
22362238
brain = self.brain_matrix[row, col]
2237-
gviews = map(brain._xfm_view, views)
2239+
gviews = list(map(brain._xfm_view, views))
22382240
allowed = ('lateral', 'caudal', 'medial', 'rostral')
22392241
if not len([v for v in gviews if v in allowed]) == len(gviews):
22402242
raise ValueError('Animate through %s views.' % ' '.join(allowed))

0 commit comments

Comments
 (0)