Skip to content

Commit 5427538

Browse files
authored
Merge pull request #1656 from oesteban/fix/ParameterizedPaths
[FIX] Several fixes related to unicode literals
2 parents acff08d + 648e80b commit 5427538

File tree

12 files changed

+147
-146
lines changed

12 files changed

+147
-146
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Upcoming release 0.13
22
=====================
33

4+
* FIX: Minor bugfixes related to unicode literals (https://github.com/nipy/nipype/pull/1656)
45
* ENH: Add a DVARS calculation interface (https://github.com/nipy/nipype/pull/1606)
56
* ENH: New interface to b0calc of FSL-POSSUM (https://github.com/nipy/nipype/pull/1399)
67
* ENH: Convenient load/save of interface inputs (https://github.com/nipy/nipype/pull/1591)

nipype/algorithms/modelgen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ def _generate_design(self, infolist=None):
547547
out = np.array([])
548548

549549
if out.size > 0:
550-
iflogger.debug('fname=%s, out=%s, nscans=%s', filename, out, repr(sum(nscans[0:i])))
550+
iflogger.debug('fname=%s, out=%s, nscans=%d', filename, out, sum(nscans[0:i]))
551551
sumscans = out.astype(int) + sum(nscans[0:i])
552552

553553
if out.size == 1:

nipype/caching/memory.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,9 @@ def __call__(self, **kwargs):
9393
return out
9494

9595
def __repr__(self):
96-
return '%s(%s.%s, base_dir=%s)' % (self.__class__.__name__,
97-
self.interface.__module__,
98-
self.interface.__name__,
99-
self.base_dir)
96+
return '{}({}.{}}, base_dir={})'.format(
97+
self.__class__.__name__, self.interface.__module__, self.interface.__name__,
98+
self.base_dir)
10099

101100
################################################################################
102101
# Memory manager: provide some tracking about what is computed when, to
@@ -302,5 +301,4 @@ def _clear_all_but(self, runs, warn=True):
302301
job_names, warn=warn)
303302

304303
def __repr__(self):
305-
return '%s(base_dir=%s)' % (self.__class__.__name__,
306-
self.base_dir)
304+
return '{}(base_dir={})'.format(self.__class__.__name__, self.base_dir)

nipype/external/due.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def nondecorating_decorator(func):
4242
cite = load = add = _donothing
4343

4444
def __repr__(self):
45-
return self.__class__.__name__ + '()'
45+
return '{}()'.format(self.__class__.__name__)
4646

4747

4848
def _donothing_func(*args, **kwargs):

nipype/interfaces/base.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from ..utils.provenance import write_provenance
3838
from ..utils.misc import is_container, trim, str2bool
3939
from ..utils.filemanip import (md5, hash_infile, FileNotFoundError, hash_timestamp,
40-
split_filename, encode_dict)
40+
split_filename, to_str)
4141
from .traits_extension import (
4242
traits, Undefined, TraitDictObject, TraitListObject, TraitError, isdefined, File,
4343
Directory, DictStrStr, has_metadata)
@@ -72,7 +72,7 @@ def __init__(self, value):
7272
self.value = value
7373

7474
def __str__(self):
75-
return repr(self.value)
75+
return '{}'.format(self.value)
7676

7777
def _exists_in_path(cmd, environ):
7878
"""
@@ -271,7 +271,7 @@ def _get_bunch_hash(self):
271271
# Sort the items of the dictionary, before hashing the string
272272
# representation so we get a predictable order of the
273273
# dictionary.
274-
sorted_dict = encode_dict(sorted(dict_nofilename.items()))
274+
sorted_dict = to_str(sorted(dict_nofilename.items()))
275275
return dict_withhash, md5(sorted_dict.encode()).hexdigest()
276276

277277
def __pretty__(self, p, cycle):
@@ -381,7 +381,7 @@ def __repr__(self):
381381
outstr = []
382382
for name, value in sorted(self.trait_get().items()):
383383
outstr.append('%s = %s' % (name, value))
384-
return '\n' + '\n'.join(outstr) + '\n'
384+
return '\n{}\n'.format('\n'.join(outstr))
385385

386386
def _generate_handlers(self):
387387
"""Find all traits with the 'xor' metadata and attach an event
@@ -581,7 +581,7 @@ def get_hashval(self, hash_method=None):
581581
dict_withhash.append((name,
582582
self._get_sorteddict(val, True, hash_method=hash_method,
583583
hash_files=hash_files)))
584-
return dict_withhash, md5(encode_dict(dict_nofilename).encode()).hexdigest()
584+
return dict_withhash, md5(to_str(dict_nofilename).encode()).hexdigest()
585585

586586

587587
def _get_sorteddict(self, objekt, dictwithhash=False, hash_method=None,
@@ -808,10 +808,13 @@ def help(cls, returnhelp=False):
808808
def _refs_help(cls):
809809
""" Prints interface references.
810810
"""
811+
if not cls.references_:
812+
return []
813+
811814
helpstr = ['References::']
812815

813816
for r in cls.references_:
814-
helpstr += [repr(r['entry'])]
817+
helpstr += ['{}'.format(r['entry'])]
815818

816819
return helpstr
817820

nipype/interfaces/fsl/dti.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ def _list_outputs(self):
946946
cwd, base_name = os.path.split(name)
947947
outputs['out_files'].append(self._gen_fname(
948948
base_name, cwd=cwd,
949-
suffix='_proj_seg_thr_' + repr(self.inputs.threshold)))
949+
suffix='_proj_seg_thr_{}'.format(self.inputs.threshold)))
950950
return outputs
951951

952952

nipype/pipeline/engine/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def __repr__(self):
105105
if self._hierarchy:
106106
return '.'.join((self._hierarchy, self._id))
107107
else:
108-
return self._id
108+
return '{}'.format(self._id)
109109

110110
def save(self, filename=None):
111111
if filename is None:

0 commit comments

Comments
 (0)