2

I am using numba (0.10.2-5-gda3e2bb-dirty) to speed up my code. Now I am trying the following:

from numba import void, int_, double, jit
import numpy as np

@jit
class bla(object)

    @void
    def my_fun
    k = np.int_(1)
    f = np.int_(np.array([1, 2 , 3, 4, 5]))
    if k in f:
        do something

However numba appears to choke on the in command. If I type something like

if k == 1:

everything is fine. However with the in command numba won't compile. Any thoughts?

Btw: I am running python 2.7 and

numpy.version

returns

numpy-1.7.1-py2.7-linux-i686.egg

Thanks in advance!

Nick

1 Answer 1

1

There are a number of basic issues with your code syntax (indentation, missing parentheses, etc.), but if I re-write it as follows, I an error message that in type comparisons are not implemented yet:

NumbaError: (see below)
--------------------- Numba Encountered Errors or Warnings ---------------------
Error <class '_ast.In'> comparisons not yet implemented
--------------------------------------------------------------------------------

import numpy as np
from numba import void, int_, double, jit

@jit
class bla(object):
    @void()
    def __init__(self):
        self.x = 1

    @void()
    def my_fun(self):
        self.x = 1
        k = np.int_(1)
        f = np.int_(np.array([1, 2 , 3, 4, 5]))
        if k in f:
            print 'aaa'

I had to throw in the self.x lines because numba seems to fail on compile with unused variables, including self.

Sign up to request clarification or add additional context in comments.

3 Comments

Sorry about the missing parentheses, this was something I threw together for illustration purposes. In any case, I programmed around the problem in another way. I see the error message too. I guess, we just have to be patient. Thanks for the answer!
@Verfblikje Just as a note, when you post a question, you should try to include runnable code that produces the error or problem that you are asking about.
Will do next time! Thanks for the help in any case!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.