Skip to content

Node de-listifies output lists with a single element #2670

Closed
@effigies

Description

@effigies

Summary / Actual behavior

A Select interface can return a single-element list, when that is the element selected. However, if placed in a Node, this will be unwrapped and the output will be the element itself.

Expected behavior

Node should not modify the outputs of an interface.

How to replicate the behavior

from nipype.pipeline import engine as pe
from nipype.interfaces import utility as niu

select_if = niu.Select(inlist=[[1, 2, 3], [4]], index=1)
select_nd = pe.Node(niu.Select(inlist=[[1, 2, 3], [4]], index=1), name='select_nd')

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

assert ifres.outputs.out == [4]
assert ndres.outputs.out == 4

Platform details:

{'pkg_path': '/anaconda3/lib/python3.6/site-packages/nipype',
 'commit_source': 'archive substitution',
 'commit_hash': '%h',
 'nipype_version': '1.1.0',
 'sys_version': '3.6.5 |Anaconda, Inc.| (default, Apr 26 2018, 08:42:37) \n[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]',
 'sys_executable': '/anaconda3/bin/python',
 'sys_platform': 'darwin',
 'numpy_version': '1.14.3',
 'scipy_version': '1.1.0',
 'networkx_version': '2.1',
 'nibabel_version': '2.3.0',
 'traits_version': '4.6.0'}
1.1.0

Execution environment

Choose one

  • My python environment outside container

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions