|
6 | 6 | import pytest
|
7 | 7 |
|
8 | 8 | from nipype.interfaces import utility
|
| 9 | +from nipype.interfaces.base import isdefined |
9 | 10 | import nipype.pipeline.engine as pe
|
10 | 11 |
|
11 | 12 |
|
@@ -49,3 +50,28 @@ def test_split(tmpdir, args, expected):
|
49 | 50 | res = node.run()
|
50 | 51 | assert res.outputs.out1 == expected[0]
|
51 | 52 | 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