InsightSoftwareConsortium / InsightSoftwareConsortium/ITK
ITK filter methods that want a sequence of ints get confused when passed a sequence of np.int64s
- Dominant language
- C++
- Stars
- 1.7k
- Forks
- 748
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 64
Description
### Description
When you index into a numpy array and think you got an integer, you actually get a numpy.int64. python ints and numpy.int64 are almost indistinguishable, but If you pass a sequence of numpy.int64 s to an ITK method that expects a sequence of integers,
it throws an inscrutable error. This is unpleasant to debug.
### Steps to Reproduce
```python
import itk
import numpy as np
crop_amounts = np.array([1, 2, 3])
crop_amounts = [i for i in crop_amounts]
print(crop_amounts)
# [1, 2, 3]
filter = itk.CropImageFilter[itk.Image[itk.F, 3], itk.Image[itk.F, 3]].New()
filter.SetLowerBoundaryCropSize(crop_amounts)
```
### Expected behavior
sets the lower boundary
### Actual behavior
```none
Traceback (most recent call last):
File "", line 8, in
ValueError: Expecting a sequence of int (or long)
```
### Reproducibility
100%
### Versions
any
### Environment
any
### Additional Information
Contributor guide
Assessment
This issue has not been assessed yet.