I can't get the following code to jit using numba. Is there an alternative method? I want the result to be an array of strings. The code runs exactly as expected without the numba jit.
from numba import jit
import numpy as np
@jit(nopython=True)
def test():
chars = np.array([[97, 98, 99, 0, 0],[99, 98, 97, 0, 0]], dtype=np.uint8)
return chars.view(dtype='<S5').astype(str).squeeze()
test()
CodePudding user response:
I asked about this on the numba gitter channel was told that this isn't supported. I settled for the following. There is additional processing in the real function which is jittable and pulling out this last small part allowed the speed ups to take place on all the rest to great effect.
from numba import jit
import numpy as np
@jit(nopython=True)
def test():
chars = np.array([[97, 98, 99, 0, 0],[99, 98, 97, 0, 0]], dtype=np.uint8)
dtypes5 = np.dtype('<S5')
return chars.view(dtypes5)
test().astype(str).squeeze()