Skip to content

Commit 2534772

Browse files
committed
TEST: Test interfaces.utility.Merge
1 parent 30ab0e1 commit 2534772

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

nipype/interfaces/utility/tests/test_base.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytest
77

88
from nipype.interfaces import utility
9+
from nipype.interfaces.base import isdefined
910
import nipype.pipeline.engine as pe
1011

1112

@@ -49,3 +50,28 @@ def test_split(tmpdir, args, expected):
4950
res = node.run()
5051
assert res.outputs.out1 == expected[0]
5152
assert res.outputs.out2 == expected[1]
53+
54+
55+
@pytest.mark.parametrize("args, kwargs, in_lists, expected", [
56+
([3], {}, [0, [1, 2], [3, 4, 5]], [0, 1, 2, 3, 4, 5]),
57+
([], {}, None, None),
58+
([3], {'axis': 'hstack'}, [[0], [1, 2], [3, 4, 5]], [[0, 1, 3]]),
59+
([3], {'axis': 'hstack'}, [[0, 1], [2, 3], [4, 5]],
60+
[[0, 2, 4], [1, 3, 5]]),
61+
([3], {'axis': 'hstack'}, [[0, 1], [2, 3], [4, 5]],
62+
[[0, 2, 4], [1, 3, 5]]),
63+
])
64+
def test_merge(tmpdir, args, kwargs, in_lists, expected):
65+
os.chdir(str(tmpdir))
66+
67+
node = pe.Node(utility.Merge(*args, **kwargs), name='merge')
68+
69+
numinputs = args[0] if args else 0
70+
for i in range(1, numinputs + 1):
71+
setattr(node.inputs, 'in{:d}'.format(i), in_lists[i - 1])
72+
73+
res = node.run()
74+
if numinputs == 0:
75+
assert not isdefined(res.outputs.out)
76+
else:
77+
assert res.outputs.out == expected

0 commit comments

Comments
 (0)