Reputation: 12747
I have the following class definition:
class GentleBoostC(object):
def __init__(self):
# do init stuff
# add jit in order to speed up the code
@jit
@void (float_[:,:],int_[:],int_)
def train(self, X, y, H):
# train do stuff
Then, in another file, I do this:
import GentleBoostC as gbc
# initialize the 2D array X_train, the 1D array y_train, and the integer boosting_rounds
gentlebooster = gbc.GentleBoostC()
gentlebooster.train(X_train,y_train,boosting_rounds)
But then I get this error:
Traceback (most recent call last):
File "C:\Users\app\Documents\Python Scripts\gbc_classifier_train.py", line 53, in <module>
gentlebooster.train(X_train,y_train,boosting_rounds)
TypeError: _jit_decorator() takes exactly 1 argument (4 given)
I find decorators so confusing, and it wasn't until this error that I realized that the jit
implementation uses decorators too! Or at least I'm guessing it does.
Upvotes: 0
Views: 377
Reputation: 216
There are three problems here:
1) The latest Numba (version 0.14) does not support jitting classes or class methods (jitting classes was lost in the 0.12 refactor, but will probably be added back soon).
2) There is no void decorator (although it's possible this existed in a previous version - I don't remember).
3) The function signature isn't specified correctly in the jit decorator. It should be something like: @jit(void(float_[:,:], int_[:], int_)) for a function that takes a 2d float array, a 1d int array, and an int, and returns nothing. You could also specify it as a string: @jit('void(f4[:,:], i4[:], i4')
Upvotes: 1