Skip to content

Commit e6bf7d5

Browse files
committed
fixing python 2 compatibility
1 parent 632c1f1 commit e6bf7d5

File tree

11 files changed

+44
-34
lines changed

11 files changed

+44
-34
lines changed

nipype/interfaces/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,10 +1832,12 @@ def _parse_inputs(self, skip=None):
18321832
if skip and name in skip:
18331833
continue
18341834
value = getattr(self.inputs, name)
1835-
if spec.genfile or spec.name_source:
1835+
if spec.name_source:
18361836
value = self._filename_from_source(name)
1837-
if not isdefined(value):
1837+
elif spec.genfile:
1838+
if not isdefined(value) or value is None:
18381839
value = self._gen_filename(name)
1840+
18391841
if not isdefined(value):
18401842
continue
18411843
arg = self._format_arg(name, spec, value)

nipype/interfaces/fsl/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
from glob import glob
3232
import os
3333

34+
from ... import logging
3435
from ...utils.filemanip import fname_presuffix
3536
from ..base import traits, isdefined, CommandLine, CommandLineInputSpec
3637

38+
LOGGER = logging.getLogger('interface')
3739

3840

3941
class Info(object):
@@ -110,8 +112,8 @@ def output_type(cls):
110112
try:
111113
return os.environ['FSLOUTPUTTYPE']
112114
except KeyError:
113-
warnings.warn(('FSL environment variables not set. setting output '
114-
'type to NIFTI'))
115+
LOGGER.warn('FSLOUTPUTTYPE environment variable is not set. '
116+
'Setting FSLOUTPUTTYPE=NIFTI')
115117
return 'NIFTI'
116118

117119
@staticmethod

nipype/interfaces/fsl/dti.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from builtins import range
1717

1818
import os
19+
import warnings
1920

2021
from ...utils.filemanip import fname_presuffix, split_filename, copyfile
2122
from ..base import (TraitedSpec, isdefined, File, Directory,

nipype/interfaces/fsl/epi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import os
1818
import numpy as np
1919
import nibabel as nib
20+
import warnings
2021

2122
from ...utils.filemanip import split_filename
2223
from ..base import (traits, TraitedSpec, InputMultiPath, File,

nipype/interfaces/meshfix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def _list_outputs(self):
128128
return outputs
129129

130130
def _gen_filename(self, name):
131-
if name is 'out_filename':
131+
if name == 'out_filename':
132132
return self._gen_outfilename()
133133
else:
134134
return None

nipype/interfaces/traits_extension.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from traits.api import BaseUnicode
3434
from traits.api import Unicode
3535

36-
DictStrStr = traits.Dict(str, str)
36+
DictStrStr = traits.Dict(str, (bytes, str))
3737
Str = Unicode
3838

3939
class BaseFile(BaseUnicode):

nipype/pipeline/engine/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import re
2525
import numpy as np
2626
from ... import logging
27+
from ...interfaces.base import DynamicTraitedSpec
2728
from ...utils.filemanip import loadpkl, savepkl
28-
from ..interfaces.base import DynamicTraitedSpec
2929

3030
logger = logging.getLogger('workflow')
3131

nipype/pipeline/engine/nodes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
from ...interfaces.base import (traits, InputMultiPath, CommandLine,
4747
Undefined, TraitedSpec, DynamicTraitedSpec,
4848
Bunch, InterfaceResult, md5, Interface,
49-
TraitDictObject, TraitListObject, isdefined)
49+
TraitDictObject, TraitListObject, isdefined,
50+
runtime_profile)
5051
from .utils import (generate_expanded_graph, modify_paths,
5152
export_graph, make_output_dir, write_workflow_prov,
5253
clean_working_directory, format_dot, topological_sort,

nipype/utils/tests/test_cmd.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def capture_sys_output():
2626

2727

2828
class TestNipypeCMD(unittest.TestCase):
29+
maxDiff = None
2930

3031
def test_main_returns_2_on_empty(self):
3132
with self.assertRaises(SystemExit) as cm:
@@ -113,13 +114,13 @@ def test_run_4d_realign_without_arguments(self):
113114
in_file [in_file ...]
114115
tr"""
115116

116-
if PY2:
117+
if PY3:
117118
error_message += """
118-
nipype_cmd nipype.interfaces.nipy FmriRealign4d: error: too few arguments
119+
nipype_cmd nipype.interfaces.nipy FmriRealign4d: error: the following arguments are required: in_file, tr
119120
"""
120-
elif PY3:
121+
else:
121122
error_message += """
122-
nipype_cmd nipype.interfaces.nipy FmriRealign4d: error: the following arguments are required: in_file, tr
123+
nipype_cmd nipype.interfaces.nipy FmriRealign4d: error: too few arguments
123124
"""
124125

125126
self.assertEqual(stderr.getvalue(), error_message)

nipype/workflows/dmri/fsl/tests/test_dti.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals, print_function, absolute_import
23
import os
34

45
from nipype.testing import skipif

0 commit comments

Comments
 (0)