【发布时间】:2020-03-10 07:23:27
【问题描述】:
我希望 B 类包含 A 对象的列表,如下所示:
from numba import int8, jitclass, types, typed
@jitclass([("field", int8)])
class A:
def __init__(self):
self.field = 1
@jitclass([("container", types.ListType(A))])
class B:
def __init__(self):
self.container = typed.List(A())
if __name__ == "__main__":
b = B()
错误:
Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<class 'numba.types.containers.ListType'>) with argument(s) of type(s): (instance.jitclass.A#7f994ec4a860<field:int8>)
* parameterized
In definition 0:
TypeError: typer() takes 0 positional arguments but 1 was given
raised from /home/xxx/miniconda3/envs/yyy/lib/python3.7/site-packages/numba/typing/templates.py:283
In definition 1:
TypeError: typer() takes 0 positional arguments but 1 was given
raised from /home/xxx/miniconda3/envs/yyy/lib/python3.7/site-packages/numba/typing/templates.py:283
This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: typeref[<class 'numba.types.containers.ListType'>]
我哪里做错了...?还是不支持此功能? Numba 0.48,Python 3.7
【问题讨论】:
标签: numba