【发布时间】:2021-06-09 19:51:54
【问题描述】:
这是我的代码。
from numba import jit
import numpy as np
import time
from pandas.core.common import flatten
from numba import njit
b_wi=[[1,2,3,4],[6,7,8,9,10,11]] #b_wi is a subset of x
f_wi=[[5,4,2,7,9],[5,4,3,7,2,3,4]]
# @jit(nopython=True)
def stopF_w(x,b_wi,f,di):
if di=='left':
return f[np.searchsorted(-b_wi,-x,side='left')]
if di=='right':
return f[np.searchsorted( b_wi, x,side='right')]
# this f :need to be an element in f_nslst
#b_wi :need to be an element in b_wilst
@njit(parallel=True)
def averageF_w(x,b_wilst,f_nslst,di):
a=np.zeros(x.shape[0])
for b_wi,f in zip(b_wilst,f_nslst):
a[:] += stopF_w(x,np.asarray(b_wi),np.asarray(f),di)
return a
intval= np.unique(list(flatten(b_wi)))
x=np.concatenate(([-10000],(intval[:-1]+intval[1:])/2,[10000])) #b_wi is a subset of x. That is why I can use this.
averageF_w(x,b_wi,f_wi,'right')
它引发错误:TypingError:无法确定
【问题讨论】:
-
请只发布代码中绝对相关的部分
-
很抱歉,您认为哪一部分不相关?