Skip to content
Advertisement

Numba cannot determine fingerprint of empty list even with signature

I am using the @jit signature to define the types of the incoming arguments. But in calling the function I get:

JavaScript

I know the list is empty, but my signature defines it so am not sure why Numba does not use that signature.

I have tried the different forms of signatures (string form and the tuple form) and it still gives the error. It is not clear to me from the documentation why these signatures do not define the arguments as passed in and it is still relying on inferring types.

JavaScript

I expected the signature to enforce a data typing on the incoming arguments with no need for inferring the data types. Actual error

JavaScript

Advertisement

Answer

So I found a workaround to get your code to working. Here is a github issue with almost the same problem as you are facing. So I tried to create a List with a dummy value -1 which will be dropped towards the end. However, I ran into an ‘reflected List exception`. You can read about it more here. So I had to use Numba’s typed-list. You can check more about this data type here. Long story short, here is the final code that works in No Python mode and returns the correct result as you would expect.

JavaScript

Here is the link to Google colab notebook with the working code. Go to the last cell if you want to dig into the reflected list exception.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement