Error while trying to write a simple example using Numba

0 views
Skip to first unread message

Veeresh Taranalli

unread,
Aug 19, 2012, 2:38:19 AM8/19/12
to numba...@continuum.io
Hi

I am trying to write a simple example using Numba as follows

==============================================================
from numba import d, i
from numba.decorators import jit as jit
import numpy as np

def viterbi_decode(coded_bits, k, n, total_memory):
    rate = k/n
    return rate

viterbi_decode_numba = jit(ret_type=d, arg_types=[d[:], d, d, i])(viterbi_decode)
cbits = np.array([1,0,1,1,0,1,1], dtype=float)
k = 1
n = 3
total_memory = 6
rate = viterbi_decode_numba(cbits, k, n, total_memory)
print rate
===============================================================

The error i get is as follows:

===============================================================
Traceback (most recent call last):
  File "viterbi_numba.py", line 14, in <module>
    viterbi_decode_numba = jit(ret_type=d, arg_types=[d[:], d, d, i])(viterbi_decode)
  File "/usr/local/lib/python2.7/dist-packages/numba/decorators.py", line 81, in _jit
    return t.get_ctypes_func(llvm)
  File "/usr/local/lib/python2.7/dist-packages/numba/translate.py", line 1145, in get_ctypes_func
    for x in self.arg_types])
  File "/usr/local/lib/python2.7/dist-packages/numba/translate.py", line 377, in convert_to_ctypes
    dtype_str = np.dtype(typ).str
TypeError: data type not understood
================================================================

However this error goes away if i pass the last argument 'total_memory' as a double, i.e., d instead of i in the arg_types list.

Any ideas if I am doing something the wrong way?

Thanks,
Veeresh Taranalli



Jon Riehl

unread,
Aug 23, 2012, 4:48:17 PM8/23/12
to numba...@continuum.io
This is a bug in how the numba.i type gets translated to another
internal type language. The work around is to use the (soon to be
deprecated) string type declaration for your integer types.

So try (notice the quotes around the i in arg_types):

viterbi_decode_numba = jit(ret_type=d, arg_types=[d[:], d, d,
'i'])(viterbi_decode)

This should work until we get a fix.

Thanks,
-Jon
> --
> You received this message because you are subscribed to the Google Groups
> "Numba Discussion" group.
> To post to this group, send email to numba...@continuum.io.
> To unsubscribe from this group, send email to
> numba-users...@continuum.io.
> To view this discussion on the web visit
> https://groups.google.com/a/continuum.io/d/msg/numba-users/-/J6ArY4mpxCEJ.
> For more options, visit
> https://groups.google.com/a/continuum.io/groups/opt_out.
>
>
Reply all
Reply to author
Forward
0 new messages