I have the following array:
import numpy as np
from numba import njit
test_array = np.random.rand(4, 10)
I create a "jitted" function that slices the array and does some operations afterwards:
@njit(fastmath = True)
def test_function(array):
test_array_sliced = test_array[[0,1,3]]
return test_array_sliced
However, Numba throws the following error:
In definition 11:
TypeError: unsupported array index type list(int64) in [list(int64)]
raised from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numba/typing/arraydecl.py:71
This error is usually caused by passing an argument of a type that is unsupported by the named function.
Workaround
I have tried to delete the rows I do not need by using np.delete, but since I have to specify an axis Numba throws the following error:
@njit(fastmath = True)
def test_function(array):
test_array_sliced = np.delete(test_array, obj = 2, axis = 0)
return test_array_sliced
In definition 1:
TypeError: np_delete() got an unexpected keyword argument 'axis'
raised from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numba/typing/templates.py:475
This error is usually caused by passing an argument of a type that is unsupported by the named function.
Any ideas of how to extract specific rows under Numba?