Anyone can help? please. Cannot determine Numba type of <class ‘type’>. This is my code and the input xq is a (N,3) ndarray.
@njit(parallel=True)
def fraction_field(xq):
N = 15
none = np.nan
fq = np.zeros((xq.shape[0],))
delta = 5
tt = np.arange(0, 360, delta, dtype=float) / 180 * pi
pp = np.arange(0, 180, delta, dtype=float) / 180 * pi
theta, phi = np.meshgrid(tt, pp)
theta = theta.reshape((-1,))
phi = phi.reshape((-1,))
offset = np.array(
[
d / 2 * np.sin(phi) * np.cos(theta),
d / 2 * np.sin(phi) * np.sin(theta),
d / 2 * np.cos(phi),
]
).T
for j in prange(xq.shape[0]):
if j % 1000==0:
print(j)
R_xq = np.sqrt((xq[j, 0] - x) ** 2 + (xq[j, 2] - z) ** 2)
if R_xq <= r:
fq[j] = none
else:
dist = np.sqrt(np.sum((pos - xq[j, :]) ** 2, axis=1))
R_list = np.array([np.arange(dist.shape[0], dtype=float), dist]).T
R_list = R_list[R_list[:, 1].argsort(), :]
idx_N = R_list[:N, 0].astype(int)
pos_N = pos[idx_N, :]
point = np.zeros((N, theta.shape[0], 3))
for i in range(N):
point[i, :, :] = pos_N[i, :] + offset
point = point.reshape((-1, 3))
vol = ConvexHull(point).volume
fq[j] = N * 4 / 3 * pi * (d / 2) ** 3 / vol
return fq
And a error occured:
Traceback (most recent call last):
File “C:\Users\chinylan\Desktop\ConvexHull\convex_fraction.py”, line 127, in
frac = fraction_field(Xq)
File “C:\Users\chinylan\Desktop\ConvexHull\convex_fraction.py”, line 106, in fraction_field
fq=loop()
File “C:\Users\chinylan\anaconda3\lib\site-packages\numba\core\dispatcher.py”, line 482, in _compile_for_args
error_rewrite(e, ‘typing’)
File “C:\Users\chinylan\anaconda3\lib\site-packages\numba\core\dispatcher.py”, line 423, in error_rewrite
raise e.with_traceback(None)
TypingError: Cannot determine Numba type of <class ‘type’>