Skip to content

[BUG] nipype.interfaces.utility.Select can accept False but not np.False_ #959

@man-shu

Description

@man-shu

What happened?

In

currently, the output of

def compare_xforms(lta_list, norm_threshold=15):
is a np.bool instead of a bool. So when we pass that to the select_transform.inputs.index in
(compare_transforms, select_transform, [('out', 'index')]),
it throws the following error:

traits.trait_errors.TraitError: Each element of the 'index' trait of a SelectInputSpec instance must be an integer, but a value of np.False_ <class 'numpy.bool'> was specified.

Using, say, False as an input to the same parameter works fine. I have attached some code to reproduce the issue.

What command did you use?

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

select_transform = pe.Node(niu.Select(), run_without_submitting=True, name='select_transform')

# the following fails
select_transform.inputs.trait_set(inlist=[1, 2, 3], index=np.False_)

## Gives the error
## traits.trait_errors.TraitError: Each element of the 'index' trait of a SelectInputSpec instance must be an integer, but a value of np.False_ <class 'numpy.bool'> was specified.

# but the following works
select_transform.inputs.trait_set(inlist=[1, 2, 3], index=False)
out = select_transform.run()
out.outputs.out

## returns the first element of inlist
## 1

What version of the software are you running?

1.12.1

How are you running this software?

Docker

Is your data BIDS valid?

Yes

Are you reusing any previously computed results?

FreeSurfer

Please copy and paste any relevant log output.

Additional information / screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions