Signature Errors When Using Classes With Numba

Change It seems that the problem is not really related to the fact that classes are changing. I don't seem to have any classes for working with Numba. By executing (as an example) the code here , it generates errors related to signatures:

Traceback (most recent call last): File "numba_test.py", line 7, in <module> class test_base_class_numba(object): File "numba_test.py", line 8, in test_base_class_numba @numba.void() TypeError: 'Signature' object is not callable 

I have a class in Python that changes to the second type of class depending on some initial conditions. When I try to compile this class with Numba, I get a cryptic error. This is best illustrated by an example:

 import numba @numba.jit class First(): def __init__(self, test): self.some_inherited_property = 1 if test: self.__class__ = SecondA else: self.__class__ = SecondB class SecondA(First): def some_func_a(): print "I am class SecondA" class SecondB(First): def some_func_b(): print "I am class SecondB" thing = First(False) 

When I run this code, I get the following error:

 Traceback (most recent call last): File "numba_test.py", line 3, in <module> @numba.jit File ".../numba/decorators.py", line 155, in jit targetoptions=options) File ".../numba/dispatcher.py", line 262, in __init__ pysig = utils.pysignature(py_func) File ".../funcsigs/__init__.py", line 176, in signature raise ValueError('callable {0!r} is not supported by signature'.format(obj)) ValueError: callable <class __main__.First at 0x7f37696fb4c8> is not supported by signature 

Setting (what I think) a signature with something like @numba.jit("numba.void(numba.bool)") on line 3 does not help.

+4
source share
2 answers

Recent versions of numba do not support jit'ing classes. This was possible in older versions, but was removed due to poor performance in one of the latest refactoring. See here .

The next version of Numba (0.20.1) should re-enable support for them. See the discussion on the mailing list .

+3
source

The above answer is a bit outdated. Since version 0.23.0 , numba again has class support using the jitclass decorator.

0
source

All Articles