ITK
ITK copied to clipboard
ITK filter methods that want a sequence of ints get confused when passed a sequence of np.int64s
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
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
Traceback (most recent call last):
File "<stdin>", line 8, in <module>
ValueError: Expecting a sequence of int (or long)
Reproducibility
100%
Versions
any
Environment
any