Whenever I try to use @jit on my class method, I get IndentationError: unexpected indent

荒凉一梦 提交于 2019-11-30 16:14:26

From what I can see from the documentation, you cannot apply the decorator to a method; the error you see is from the JIT parser not handling the source code indentation when not in the context of a class statement.

If you want the body of that method to be compiled, you'll need to factor it out to a separate function, and call that function from the method:

@jit(void(object_, float_[:,:], int_[:], int_)) 
def train_function(instance, X, y, H):
    # do stuff

class GentleBoostC(object):
    def train(self, X, y, H):
        train_function(self, X, y, H)    
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!