[BUG] nipype.interfaces.utility.Select can accept `False` but not `np.False_`
What happened?
In https://github.com/nipreps/niworkflows/blob/0fdca352a9ef94207407feb34bf11bc071e0eb8a/niworkflows/anat/coregistration.py#L32
currently, the output of https://github.com/nipreps/niworkflows/blob/0fdca352a9ef94207407feb34bf11bc071e0eb8a/niworkflows/anat/coregistration.py#L297 is a np.bool instead of a bool. So when we pass that to the select_transform.inputs.index in https://github.com/nipreps/niworkflows/blob/0fdca352a9ef94207407feb34bf11bc071e0eb8a/niworkflows/anat/coregistration.py#L283 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
Just to check, does this occur on numpy<2, or is this a new change?
Ah good catch! Seems like the cause is a deprecation in 2.3.0: https://github.com/numpy/numpy/releases/tag/v2.3.0
Okay, probably the fix is to change it to traits.Either(traits.Int, traits.Bool) and then use int(self.inputs.index) internally.
This needs to be fixed in nipype.