Cannot cast array(int64, 1d, C) to int32

Hello!

I am new to Numba and I have been having some troubles with the data types, I tried to convert an np.int64 to np.int32, I kept tracing and discovered that the problem was the conversion from int64, however I have no clue of what could I try to solve it:
Cannot cast array(int64, 1d, C) to int32: %".7980" = load {i8*, i8*, i64, i64, i64*, [1 x i64], [1 x i64]}, {i8*, i8*, i64, i64, i64*, [1 x i64], [1 x i64]}* %"$350binary_subscr.172"

I have made an example:
import numpy as np

import numba

from numba import jit

@jit(nopython=True,nogil=True)   

def t_corrido_i():

    grafo_e=np.array([[0,1,12],[0,2,12],[0,3,12]],dtype=np.int32)

    tarefas_pj=np.array([ 0,  9, 13, 15, 16])

    requere_nodes=grafo_e[np.where(grafo_e[:,1]==3)][:,0]

    # Alternative for np.isin for numba

    requere_no_outro_proc=np.array([x in set(requere_nodes) for x in tarefas_pj])

    ix_nos_requeridos=np.int32(np.where(requere_no_outro_proc)[0])

t_corrido_i()

Does anyone have a clue of what could that be?

hi there!
Numba thinks you are trying to convert the int64 array to an int32 scalar, that’s why it complains.

you can achieve the conversion to int32 by writing ix_nos_requeridos=np.where(requere_no_outro_proc)[0].astype(np.int32)

cheers,
Luk

Thanks so much! It worked out perfectly!

Opened numpy constructors aren't typing correctly, invalid cast issued · Issue #6656 · numba/numba · GitHub to track, it should have been caught earlier.