Skip to content

Commit 7e3393e

Browse files
committed
Merge pull request #1221 from alexsavio/enh/py3k
Apply python-future for Python 3.4 support
2 parents 11111cd + 6406ace commit 7e3393e

File tree

877 files changed

+6799
-6001
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

877 files changed

+6799
-6001
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/nipype/build
66
/nipype/nipype.egg-info
77
/doc/_build
8+
/doc/preproc
89
/doc/users/examples
910
/doc/api/generated
1011
*.pyc
@@ -17,3 +18,6 @@
1718
.DS_Store
1819
nipype/testing/data/von-ray_errmap.nii.gz
1920
nipype/testing/data/von_errmap.nii.gz
21+
crash*.pklz
22+
.coverage
23+
htmlcov/

.travis.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ cache:
33
language: python
44
python:
55
- 2.7
6+
- 3.4
67
env:
78
- INSTALL_DEB_DEPENDECIES=true
89
- INSTALL_DEB_DEPENDECIES=false
910
before_install:
1011
- if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh
11-
-O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-3.6.0-Linux-x86_64.sh
12+
-O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
1213
-O miniconda.sh; fi
1314
- chmod +x miniconda.sh
1415
- "./miniconda.sh -b"
15-
- export PATH=/home/travis/miniconda/bin:$PATH
16+
- if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then export PATH=/home/travis/miniconda/bin:$PATH; else export PATH=/home/travis/miniconda3/bin:$PATH; fi
1617
- if $INSTALL_DEB_DEPENDECIES; then sudo rm -rf /dev/shm; fi
1718
- if $INSTALL_DEB_DEPENDECIES; then sudo ln -s /run/shm /dev/shm; fi
1819
- if $INSTALL_DEB_DEPENDECIES; then bash <(wget -q -O- http://neuro.debian.net/_files/neurodebian-travis.sh);
@@ -27,15 +28,16 @@ install:
2728
- conda create -n testenv --yes pip python=$TRAVIS_PYTHON_VERSION
2829
- source activate testenv
2930
- if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then pip install ordereddict; fi
30-
- conda install --yes numpy scipy nose traits networkx dateutil
31-
- pip install nibabel
31+
- conda install --yes numpy scipy nose networkx dateutil
32+
- if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then conda install --yes traits; else pip install traits; fi
3233
- pip install python-coveralls
3334
- pip install nose-cov
35+
- pip install -r requirements.txt # finish remaining requirements
3436
- pip install https://github.com/RDFLib/rdflib/archive/master.zip
3537
- pip install https://github.com/trungdong/prov/archive/rdf.zip
3638
- python setup.py install
3739
script:
38-
- nosetests --with-doctest --with-cov --cov nipype --cov-config .coveragerc --logging-level=INFO
40+
- python -W once:FSL:UserWarning:nipype `which nosetests` --with-doctest --with-cov --cover-package nipype --cov-config .coveragerc --logging-level=INFO
3941
after_success:
4042
- coveralls --config_file .coveragerc
4143
deploy:

THANKS.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ Contributors to Nipype include but are not limited to:
1010
* Aimi Watanabe
1111
* Alexander Schaefer
1212
* Alexandre Gramfort
13+
* Alexandre Savio
1314
* Anisha Keshavan
1415
* Ariel Rokem
1516
* Ben Acland
17+
* Ben Cipollini
1618
* Basile Pinsard
1719
* Brendan Moloney
1820
* Brian Cheung

build_docs.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
python setup.py build_sphinx
99
"""
1010

11+
from __future__ import print_function
12+
1113
# Standard library imports
1214
import sys
1315
import os
@@ -43,7 +45,7 @@ def run(self):
4345
install.run()
4446

4547
# Horrible trick to reload nipype with our temporary instal
46-
for key in sys.modules.keys():
48+
for key in list(sys.modules.keys()):
4749
if key.startswith('nipype'):
4850
sys.modules.pop(key, None)
4951
sys.path.append(os.path.abspath(self.temp_install_dir))
@@ -131,7 +133,7 @@ def run(self):
131133

132134
def zip_docs(self):
133135
if not os.path.exists(DOC_BUILD_DIR):
134-
raise OSError, 'Doc directory does not exist.'
136+
raise OSError('Doc directory does not exist.')
135137
target_file = os.path.join('doc', 'documentation.zip')
136138
# ZIP_DEFLATED actually compresses the archive. However, there
137139
# will be a RuntimeError if zlib is not installed, so we check
@@ -170,17 +172,17 @@ def run(self):
170172
clean.run(self)
171173
api_path = os.path.join('doc', 'api', 'generated')
172174
if os.path.exists(api_path):
173-
print "Removing %s" % api_path
175+
print("Removing %s" % api_path)
174176
shutil.rmtree(api_path)
175177
interface_path = os.path.join('doc', 'interfaces', 'generated')
176178
if os.path.exists(interface_path):
177-
print "Removing %s" % interface_path
179+
print("Removing %s" % interface_path)
178180
shutil.rmtree(interface_path)
179181
if os.path.exists(DOC_BUILD_DIR):
180-
print "Removing %s" % DOC_BUILD_DIR
182+
print("Removing %s" % DOC_BUILD_DIR)
181183
shutil.rmtree(DOC_BUILD_DIR)
182184
if os.path.exists(DOC_DOCTREES_DIR):
183-
print "Removing %s" % DOC_DOCTREES_DIR
185+
print("Removing %s" % DOC_DOCTREES_DIR)
184186
shutil.rmtree(DOC_DOCTREES_DIR)
185187

186188

doc/devel/matlab_interface_devel.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ By subclassing **MatlabCommand** for your main class, and **MatlabInputSpec** fo
9393
>>> hello = HelloWorld()
9494
>>> hello.inputs.name = 'hello_world'
9595
>>> out = hello.run()
96-
>>> print out.outputs.matlab_output
96+
>>> print(out.outputs.matlab_output)
9797
"""
9898
input_spec = HelloWorldInputSpec
9999
output_spec = HelloWorldOutputSpec

doc/sphinxext/autosummary_generate.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
./ext/autosummary_generate.py -o source/generated source/*.rst
1717
1818
"""
19+
20+
from __future__ import print_function
1921
import glob, re, inspect, os, optparse, pydoc
2022
from autosummary import import_by_name
2123

@@ -44,7 +46,7 @@ def main():
4446

4547
# read
4648
names = {}
47-
for name, loc in get_documented(args).items():
49+
for name, loc in list(get_documented(args).items()):
4850
for (filename, sec_title, keyword, toctree) in loc:
4951
if toctree is not None:
5052
path = os.path.join(os.path.dirname(filename), toctree)
@@ -60,8 +62,8 @@ def main():
6062

6163
try:
6264
obj, name = import_by_name(name)
63-
except ImportError, e:
64-
print "Failed to import '%s': %s" % (name, e)
65+
except ImportError as e:
66+
print("Failed to import '%s': %s" % (name, e))
6567
continue
6668

6769
fn = os.path.join(path, '%s.rst' % name)
@@ -129,8 +131,8 @@ def get_documented_in_docstring(name, module=None, filename=None):
129131
return get_documented_in_lines(lines, module=name, filename=filename)
130132
except AttributeError:
131133
pass
132-
except ImportError, e:
133-
print "Failed to import '%s': %s" % (name, e)
134+
except ImportError as e:
135+
print("Failed to import '%s': %s" % (name, e))
134136
return {}
135137

136138
def get_documented_in_lines(lines, module=None, filename=None):

doc/sphinxext/numpy_ext/docscrape.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@
22
33
"""
44

5+
from __future__ import print_function
6+
from future import standard_library
7+
standard_library.install_aliases()
8+
from builtins import object
9+
510
import inspect
611
import textwrap
712
import re
813
import pydoc
9-
from StringIO import StringIO
1014
from warnings import warn
1115

16+
from nipype.external.six import StringIO
17+
18+
1219
class Reader(object):
1320
"""A line-based string reader.
1421
@@ -113,7 +120,7 @@ def __getitem__(self,key):
113120
return self._parsed_data[key]
114121

115122
def __setitem__(self,key,val):
116-
if not self._parsed_data.has_key(key):
123+
if key not in self._parsed_data:
117124
warn("Unknown section %s" % key)
118125
else:
119126
self._parsed_data[key] = val
@@ -370,7 +377,7 @@ def _str_index(self):
370377
idx = self['index']
371378
out = []
372379
out += ['.. index:: %s' % idx.get('default','')]
373-
for section, references in idx.iteritems():
380+
for section, references in list(idx.items()):
374381
if section == 'default':
375382
continue
376383
out += [' :%s: %s' % (section, ', '.join(references))]
@@ -428,7 +435,7 @@ def __init__(self, func, role='func', doc=None, config={}):
428435
argspec = inspect.formatargspec(*argspec)
429436
argspec = argspec.replace('*','\*')
430437
signature = '%s%s' % (func_name, argspec)
431-
except TypeError, e:
438+
except TypeError as e:
432439
signature = '%s()' % func_name
433440
self['Signature'] = signature
434441

@@ -450,8 +457,8 @@ def __str__(self):
450457
'meth': 'method'}
451458

452459
if self._role:
453-
if not roles.has_key(self._role):
454-
print "Warning: invalid role %s" % self._role
460+
if self._role not in roles:
461+
print("Warning: invalid role %s" % self._role)
455462
out += '.. %s:: %s\n \n\n' % (roles.get(self._role,''),
456463
func_name)
457464

doc/sphinxext/numpy_ext/docscrape_sphinx.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
from __future__ import absolute_import
12
import re, inspect, textwrap, pydoc
23
import sphinx
3-
from docscrape import NumpyDocString, FunctionDoc, ClassDoc
4-
from nipype.external import six
4+
from .docscrape import NumpyDocString, FunctionDoc, ClassDoc
5+
from nipype.external.six import string_types
6+
7+
58

69
class SphinxDocString(NumpyDocString):
710
def __init__(self, docstring, config={}):
@@ -128,7 +131,7 @@ def _str_index(self):
128131
return out
129132

130133
out += ['.. index:: %s' % idx.get('default','')]
131-
for section, references in idx.iteritems():
134+
for section, references in list(idx.items()):
132135
if section == 'default':
133136
continue
134137
elif section == 'refguide':
@@ -141,7 +144,7 @@ def _str_references(self):
141144
out = []
142145
if self['References']:
143146
out += self._str_header('References')
144-
if isinstance(self['References'], six.string_types):
147+
if isinstance(self['References'], string_types):
145148
self['References'] = [self['References']]
146149
out.extend(self['References'])
147150
out += ['']

doc/sphinxext/numpy_ext/numpydoc.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616
1717
"""
1818

19+
from __future__ import absolute_import
20+
from builtins import object
21+
1922
import sphinx
2023

2124
if sphinx.__version__ < '1.0.1':
2225
raise RuntimeError("Sphinx 1.0.1 or newer is required")
2326

2427
import os, re, pydoc
25-
from docscrape_sphinx import get_doc_object, SphinxDocString
28+
from .docscrape_sphinx import get_doc_object, SphinxDocString
2629
from sphinx.util.compat import Directive
2730
import inspect
2831

@@ -39,7 +42,7 @@ def mangle_docstrings(app, what, name, obj, options, lines,
3942
lines[:] = title_re.sub(u'', u"\n".join(lines)).split(u"\n")
4043
else:
4144
doc = get_doc_object(obj, what, u"\n".join(lines), config=cfg)
42-
lines[:] = unicode(doc).split(u"\n")
45+
lines[:] = str(doc).split(u"\n")
4346

4447
if app.config.numpydoc_edit_link and hasattr(obj, '__name__') and \
4548
obj.__name__:
@@ -120,7 +123,7 @@ def __init__(self, *a, **kw):
120123
self.wrap_mangling_directives()
121124

122125
def wrap_mangling_directives(self):
123-
for name, objtype in self.directive_mangling_map.items():
126+
for name, objtype in list(self.directive_mangling_map.items()):
124127
self.directives[name] = wrap_mangling_directive(
125128
self.directives[name], objtype)
126129

examples/dmri_camino_dti.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def get_affine(volume):
9191
"""
9292

9393
datasource = pe.Node(interface=nio.DataGrabber(infields=['subject_id'],
94-
outfields=info.keys()),
94+
outfields=list(info.keys())),
9595
name = 'datasource')
9696

9797
datasource.inputs.template = "%s/%s"

examples/dmri_connectivity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def select_aparc_annot(list_of_files):
146146
"""
147147

148148
datasource = pe.Node(interface=nio.DataGrabber(infields=['subject_id'],
149-
outfields=info.keys()),
149+
outfields=list(info.keys())),
150150
name = 'datasource')
151151

152152
datasource.inputs.template = "%s/%s"

examples/dmri_connectivity_advanced.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666

6767
try:
6868
package_check('cmp')
69-
except Exception, e:
69+
except Exception as e:
7070
warnings.warn('cmp not installed')
7171
else:
7272
import cmp
@@ -114,7 +114,7 @@
114114
"""
115115

116116
datasource = pe.Node(interface=nio.DataGrabber(infields=['subject_id'],
117-
outfields=info.keys()),
117+
outfields=list(info.keys())),
118118
name = 'datasource')
119119

120120
datasource.inputs.template = "%s/%s"

examples/dmri_dtk_dti.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"""
9999

100100
datasource = pe.Node(interface=nio.DataGrabber(infields=['subject_id'],
101-
outfields=info.keys()),
101+
outfields=list(info.keys())),
102102
name = 'datasource')
103103

104104
datasource.inputs.template = "%s/%s"

examples/dmri_dtk_odf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"""
9999

100100
datasource = pe.Node(interface=nio.DataGrabber(infields=['subject_id'],
101-
outfields=info.keys()),
101+
outfields=list(info.keys())),
102102
name = 'datasource')
103103

104104
datasource.inputs.template = "%s/%s"

examples/dmri_fsl_dti.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"""
108108

109109
datasource = pe.Node(interface=nio.DataGrabber(infields=['subject_id'],
110-
outfields=info.keys()),
110+
outfields=list(info.keys())),
111111
name = 'datasource')
112112

113113
datasource.inputs.template = "%s/%s"

examples/dmri_group_connectivity_camino.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
title = ''
127127
for idx, group_id in enumerate(group_list.keys()):
128128
title += group_id
129-
if not idx == len(group_list.keys()) - 1:
129+
if not idx == len(list(group_list.keys())) - 1:
130130
title += '-'
131131

132132
info = dict(dwi=[['subject_id', 'dti']],

examples/dmri_group_connectivity_mrtrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
title = ''
132132
for idx, group_id in enumerate(group_list.keys()):
133133
title += group_id
134-
if not idx == len(group_list.keys()) - 1:
134+
if not idx == len(list(group_list.keys())) - 1:
135135
title += '-'
136136

137137
info = dict(dwi=[['subject_id', 'dti']],

examples/dmri_mrtrix_dti.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"""
5858

5959
datasource = pe.Node(interface=nio.DataGrabber(infields=['subject_id'],
60-
outfields=info.keys()),
60+
outfields=list(info.keys())),
6161
name = 'datasource')
6262

6363
datasource.inputs.template = "%s/%s"

examples/dmri_preprocessing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"""
8282

8383
datasource = pe.Node(nio.DataGrabber(infields=['subject_id'],
84-
outfields=info.keys()), name='datasource')
84+
outfields=list(info.keys())), name='datasource')
8585

8686
datasource.inputs.template = "%s/%s"
8787

0 commit comments

Comments
 (0)