【发布时间】:2017-12-04 23:31:55
【问题描述】:
当我在使用jitclass 的类中调用函数时,我试图返回一个字符串,但出现错误:
numba.errors.InternalError: Failed at nopython (nopython mode backend)
cannot convert native const('Something') to Python object
[1] During: resolving callee type: BoundFunction((<class 'numba.types.misc.ClassInstanceType'>, 'get_Names') for instance.jitclass.myclass#3f2d488<A:float64,B:float64>)
[2] During: typing of call at <string> (3)
我正在使用这段代码来测试功能:
from numba import jitclass
from numba import boolean, int32, float64,uint8
spec = [('A' ,float64),
('B' ,float64)]
@jitclass(spec)
class myclass:
def __init__(self,):
self.A = 3.25
self.B = 22.5
def get_Names(self):
return "Something"
mC = myclass()
print(mC.get_Names())
有人知道我如何返回字符串吗?
【问题讨论】:
-
目前 numba 不支持此功能,nopython 模式通常也不支持字符串(从版本
0.36开始编写) -
是的,我明白这一点。但也许存在解决方法。也许基于 uint8 数组或类似的东西?