question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cannot determine Numba type of <class 'function'>

See original GitHub issue

I am trying to run a function in parallel mode. It is iterating over elements from a list and performing some operations. Since the elements and operations are independent of each other, the operations can be done in parallel, however when i go to compile it(i am using spyder btw) using @njit(parallel= True), I am getting an error saying that ‘cannot determine Numba type of <class ‘function’>’

The loop which is doing the iteration has functions like:

  1. Addition
  2. Division and Multiplication
  3. np.cross(cross product)
  4. np. array
  5. Calling functions that are defined earlier(outside @njit)

The error dump is pasted below:

runfile('C:/Users/Arghyadeep/Desktop/p1.py', wdir='C:/Users/Arghyadeep/Desktop')
Traceback (most recent call last):

  File "<ipython-input-38-1f08c1876264>", line 1, in <module>
    runfile('C:/Users/Arghyadeep/Desktop/p1.py', wdir='C:/Users/Arghyadeep/Desktop')

  File "C:\Users\Arghyadeep\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "C:\Users\Arghyadeep\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/Arghyadeep/Desktop/p1.py", line 73, in <module>
    parallelBoris(10)

  File "C:\Users\Arghyadeep\Anaconda3\lib\site-packages\numba\dispatcher.py", line 376, in _compile_for_args
    error_rewrite(e, 'typing')

  File "C:\Users\Arghyadeep\Anaconda3\lib\site-packages\numba\dispatcher.py", line 343, in error_rewrite
    reraise(type(e), e, None)

  File "C:\Users\Arghyadeep\Anaconda3\lib\site-packages\numba\six.py", line 658, in reraise
    raise value.with_traceback(tb)

TypingError: cannot determine Numba type of <class 'function'>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
stuartarchibaldcommented, Oct 1, 2019

Did you do something like:

In [1]: from numba import njit                                                                                                  

In [2]: def foo(x): 
   ...:     return x + 1 
   ...:                                                                                                                         

In [3]: @njit 
   ...: def call_foo(y): 
   ...:     return foo(y) 
   ...:                                                                                                                         

In [4]: call_foo(10)                

TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Untyped global name 'foo': cannot determine Numba type of <class 'function'>

File "<ipython-input-3-8c790192a815>", line 3:
def call_foo(y):
    return foo(y)
    ^                                                                                            

the root cause of which is that the functions called by @jit decorated functions also need to be @jit decorated. i.e.

In [1]: from numba import njit                                                                                                  

In [2]: @njit 
   ...: def foo(x): 
   ...:     return x + 1 
   ...:                                                                                                                         

In [3]: @njit 
   ...: def call_foo(y): 
   ...:     return foo(y) 
   ...:                                                                                                                         

In [4]: call_foo(10)                                                                                                            
Out[4]: 11
0reactions
stuartarchibaldcommented, Oct 4, 2019

Closing this issue as it seems to be resolved. If this is not the case please re-open with a comment about any item that appears to be unresolved. Many thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypingError: cannot determine Numba type of <class ...
I have a simple function to rank poker hands ...
Read more >
Cannot determine Numba type of <class 'type'> - Support
Cannot determine Numba type of <class 'type'>. This is my code and the input xq is a (N,3) ndarray. @njit(parallel=True) def fraction_field(xq): N...
Read more >
First Steps with numba — numba 0.12.0 documentation
Starting with numba version 0.12, it is possible to use numba.jit without providing a type-signature for the function. This functionality was provided by...
Read more >
TypingError: cannot determine Numba type of class ... - YouTube
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn--Music by Eric Matyashttps://www.soundimage.
Read more >
Types and signatures - Numba documentation
As an optimizing compiler, Numba needs to decide on the type of each variable to ... First-class function support is enabled for all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found