Skip to content

Commit

Permalink
fix: final fixups for tests to pass
Browse files Browse the repository at this point in the history
Modified ``test_outputmultipath_collapse`` due to a derivation of nipy#2968.
  • Loading branch information
oesteban committed Aug 1, 2019
1 parent 4f1c49c commit 5fa819f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion nipype/pipeline/engine/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ def _run_interface(self, execute=True, updatehash=False):
stop_first=str2bool(
self.config['execution']['stop_on_first_crash'])))
# And store results
_save_resultfile(result, cwd, self.name)
_save_resultfile(result, cwd, self.name, rebase=False)
# remove any node directories no longer required
dirs2remove = []
for path in glob(op.join(cwd, 'mapflow', '*')):
Expand Down
10 changes: 5 additions & 5 deletions nipype/pipeline/engine/tests/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,13 @@ def test_inputs_removal(tmpdir):
def test_outputmultipath_collapse(tmpdir):
"""Test an OutputMultiPath whose initial value is ``[[x]]`` to ensure that
it is returned as ``[x]``, regardless of how accessed."""
select_if = niu.Select(inlist=[[1, 2, 3], [4]], index=1)
select_nd = pe.Node(niu.Select(inlist=[[1, 2, 3], [4]], index=1),
select_if = niu.Select(inlist=[[1, 2, 3], [4, 5]], index=1)
select_nd = pe.Node(niu.Select(inlist=[[1, 2, 3], [4, 5]], index=1),
name='select_nd')

ifres = select_if.run()
ndres = select_nd.run()

assert ifres.outputs.out == [4]
assert ndres.outputs.out == [4]
assert select_nd.result.outputs.out == [4]
assert ifres.outputs.out == [4, 5]
assert ndres.outputs.out == [4, 5]
assert select_nd.result.outputs.out == [4, 5]
9 changes: 7 additions & 2 deletions nipype/pipeline/engine/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,14 @@ def load_resultfile(path, name, resolve=True):
finally:
pkl_file.close()

if resolve and not aggregate:
if resolve and result.outputs:
try:
outputs = result.outputs.get()
except TypeError: # This is a Bunch
return result, aggregate, attribute_error

logger.debug('Resolving paths in outputs loaded from results file.')
for trait_name, old_value in list(result.outputs.get().items()):
for trait_name, old_value in list(outputs.items()):
value = resolve_path_traits(result.outputs.trait(trait_name), old_value, path)
setattr(result.outputs, trait_name, value)

Expand Down

0 comments on commit 5fa819f

Please sign in to comment.