I have Numba 0.24 and it supports classes.
When I try to build the simplest class I can imagine I find an error! What's happening?
from numba import jitclass
@jitclass
class foo:
x = 2
bar = foo()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
3 class foo:
4 x = 2
----> 5 bar = foo()
TypeError: wrap() missing 1 required positional argument: 'cls'
Am I missing something here?
解决方案
You need to specify a spec:
spec = [('x', nb.int64)]
@nb.jitclass(spec)
class foo(object):
def __init__(self):
self.x = 2
bar = foo()
print bar.x
Take a look at the docs. At this point class variables are not supported. You have to use instance variables.