Hello
I am encountering a behavior with _numba_unpickle function, it’s taking very long. I pinned the problem down to this function:
@njit
def kim_statistics_nb(arr, tau):
nom = ((1-tau)*len(arr))**(-2)
denom = (tau*len(arr))**(-2)
break_point = int(tau*len(arr))
x0 = np.arange(1, break_point+1, 1, dtype=np.float_)
a = np.vstack((x0, np.ones(len(x0), dtype=np.float_))).T
m0, c0 = np.linalg.lstsq(a, arr[:break_point])[0]
res0 = arr[:break_point] - m0*x0+c0
x1 = np.arange(break_point+1, len(arr), 1, dtype=np.float_)
a = np.vstack((x1, np.ones(len(x1), dtype=np.float_))).T
m1, c1 = np.linalg.lstsq(a, arr[break_point+1:])[0]
res1 = arr[break_point+1:] - m1*x1+c1
cusum0_sq = np.cumsum(res0)**2
cusum1_sq = np.cumsum(res1)**2
return (nom*np.sum(cusum1_sq))/(denom*np.sum(cusum0_sq))
This function I call many times in another njit function, it’s basically a rolling calculation of the above function. The arrays passed into the above function are of size 40 and the overall array I am rolling over is 100k roughly.
Any ideas?
Cheers