如何使用numba的第三方库jit python代码?

mbskvtky  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(257)

我在做一个使用吡喹酮的项目。它的速度必须提高。为了做到这一点,我正在尝试编写jit类。这是密码

import time
from numba.experimental import jitclass
from numba import njit, jit, float64 
from pyquante2 import basisset, molecule, uhf, rhf, onee_integrals, contourplot

spec = [('int1',int64),('int2',float64),('int3',float64)]

# ,('h2',float64[:]),('bfs',float64[:]),('solver',float64[:]),('ens',float64[:])

@jitclass(spec)
class hfock(object):

    def __init__(self):
        self.int1 = 1
        self.int2 = 0.00000000 
        self.int3 = 0.36628549

    @property
    def mol(self):
        h2 = molecule([(self.int1, self.int2, self.int2, self.int3), 
                       (self.int1, self.int2, self.int2, -self.int3)], 
                        units='Angstrom')
        return h2

    def bs(self):
        bfs = basisset(self.h2, 'sto3g')
        return bfs

    def rhf(self):
        solver = rhf(self.h2, self.bfs) 
        ens = solver.converge
        return ens

然而,它给出了这个错误

TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Untyped global name 'molecule': cannot determine Numba type of <class 'type'>

File "numbatrial.py", line 29:
    def mol(self):
        h2 = molecule([(self.int1, self.int2, self.int2, self.int3), 
        ^

During: typing of get attribute at <string> (3)
During: typing of get attribute at <string> (3)

我该怎么解决这个问题?我已经做了好几天了。我查了那么多的主题和论坛。另外,我查看了numba网站的手册部分。然而,到目前为止,没有一个答案能提供令人满意的帮助。我需要的是明显而简短的解决方案,而不是含糊而复杂的解决方案。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题