I want to calculate the mean for the second index for each third index.
@njit
def mean_some_index(a):
T = a.shape[2]
b = np.zeros((T,T))
for t in range(T):
b[:, t] = a[:,:,t].mean(axis = 1)
return b
I would use it like
a = np.random.randn(5*5*5).reshape((5,5,5))
mean_some_index(a)
It is okay without Numba; however, the Numba returns an error saying:
resolving callee type: BoundFunction(array.mean for array(float64, 2d, A))
...
File "C:\Users\Mining-Base\AppData\Local\Temp\ipykernel_565300\1191607406.py", line 7:
def mean_some_index(a):
<source elided>
for t in range(T):
b[:, t] = a[:,:,t].mean(axis = 1)
I don't quite understand the error and will appreciate for who answer my question.