I’m updating this little library I have going to 25.1, and am having a bit of trouble with casting from numpy types to Mojo types.
Essentially I used to be able to cast numpy.uint8
to a Mojo Int as:
py_array[rows][columns][channels].__int__()
, where the elements of py_array are numpy.uint8
.
But now I get:
Unhandled exception caught during execution: an integer is required
.__as_int__()
has the same behaviour, as well as Int(py_array[rows][columns][channels])
. This worked at least up to 24.5, so I am trying to see in the Changelog if anything about typing changed in the meantime, but nothing stands out to me.
In the function I am trying to fix, I call I am comparing the values in a numpy array to the values in a Mojo tensor.
The numpy array is initialized as var py_array = np.array(PillowImage.open(image_path))
So is there a new/better way of casting numpy types to Mojo?