Skip to content

Commit cba8080

Browse files
committed
fix: final fixups for tests to pass
Modified ``test_outputmultipath_collapse`` due to a derivation of #2968.
1 parent 72e2e96 commit cba8080

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

nipype/pipeline/engine/nodes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ def _run_interface(self, execute=True, updatehash=False):
12581258
stop_first=str2bool(
12591259
self.config['execution']['stop_on_first_crash'])))
12601260
# And store results
1261-
_save_resultfile(result, cwd, self.name)
1261+
_save_resultfile(result, cwd, self.name, rebase=False)
12621262
# remove any node directories no longer required
12631263
dirs2remove = []
12641264
for path in glob(op.join(cwd, 'mapflow', '*')):

nipype/pipeline/engine/tests/test_nodes.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,13 @@ def test_inputs_removal(tmpdir):
295295
def test_outputmultipath_collapse(tmpdir):
296296
"""Test an OutputMultiPath whose initial value is ``[[x]]`` to ensure that
297297
it is returned as ``[x]``, regardless of how accessed."""
298-
select_if = niu.Select(inlist=[[1, 2, 3], [4]], index=1)
299-
select_nd = pe.Node(niu.Select(inlist=[[1, 2, 3], [4]], index=1),
298+
select_if = niu.Select(inlist=[[1, 2, 3], [4, 5]], index=1)
299+
select_nd = pe.Node(niu.Select(inlist=[[1, 2, 3], [4, 5]], index=1),
300300
name='select_nd')
301301

302302
ifres = select_if.run()
303303
ndres = select_nd.run()
304304

305-
assert ifres.outputs.out == [4]
306-
assert ndres.outputs.out == [4]
307-
assert select_nd.result.outputs.out == [4]
305+
assert ifres.outputs.out == [4, 5]
306+
assert ndres.outputs.out == [4, 5]
307+
assert select_nd.result.outputs.out == [4, 5]

nipype/pipeline/engine/utils.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,14 @@ def load_resultfile(path, name, resolve=True):
362362
finally:
363363
pkl_file.close()
364364

365-
if resolve and not aggregate:
365+
if resolve and result.outputs:
366+
try:
367+
outputs = result.outputs.get()
368+
except TypeError: # This is a Bunch
369+
return result, aggregate, attribute_error
370+
366371
logger.debug('Resolving paths in outputs loaded from results file.')
367-
for trait_name, old_value in list(result.outputs.get().items()):
372+
for trait_name, old_value in list(outputs.items()):
368373
value = resolve_path_traits(result.outputs.trait(trait_name), old_value, path)
369374
setattr(result.outputs, trait_name, value)
370375

0 commit comments

Comments
 (0)