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.

'Bad token in signature' with @guvectorize

See original GitHub issue
  • I have tried using the version 0.51.2 of Numba
  • I have included a self contained code sample to reproduce the problem

Hi, I am sorry, I am aware it is more a ‘usage’ question or perhaps a ‘feature request’. I have posted the question on SO here, but it does not meet much success.

Please, can we setup a constant number of columns for a result array in function signature? I have tried this way, but get here below error message.

import numpy as np
from numba import guvectorize

@guvectorize('void(float64[:], float64, uint32[:,2])', '(m),()->(m,2)', nopython=True)
def array_copy(data, delta, result):
    for i, val in np.ndenumerate(data):
        # Open i.
        i, = i
        result[i,:] = [i, int(val)+delta]

data = np.arange(3, dtype='float64')
res = np.zeros((data.shape[0], 2), dtype='uint32')
array_copy(data, 3, res)
Traceback (most recent call last):

  File "<ipython-input-17-63f8983bbf61>", line 5, in <module>
    def array_copy(data, delta, result):

  File "/home/pierre/anaconda3/lib/python3.8/site-packages/numba/np/ufunc/decorators.py", line 177, in wrap
    guvec = GUVectorize(func, signature, **kws)

  File "/home/pierre/anaconda3/lib/python3.8/site-packages/numba/np/ufunc/decorators.py", line 49, in __new__
    return imp(func, signature, identity=identity, cache=cache,

  File "/home/pierre/anaconda3/lib/python3.8/site-packages/numba/np/ufunc/ufuncbuilder.py", line 298, in __init__
    self.sin, self.sout = parse_signature(signature)

  File "/home/pierre/anaconda3/lib/python3.8/site-packages/numba/np/ufunc/sigparse.py", line 49, in parse_signature
    outputs = list(parse(outs))

  File "/home/pierre/anaconda3/lib/python3.8/site-packages/numba/np/ufunc/sigparse.py", line 35, in parse
    raise ValueError('bad token in signature "%s"' % tok[1])

ValueError: bad token in signature "2"

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
esccommented, May 28, 2021

@yohplala thank you kindly, I had missed that. I have relabelled this issue accordingly now and thank you very much for bringing this to our attention!

1reaction
esccommented, Feb 9, 2021

@yohplala so, to follow up, from what I know, the shape of the array is not part of the type specification, only the dimensionality.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'Bad token in signature' with numba & @guvectorize
When using following function signature, I get an error. import numpy as np from numba import guvectorize @guvectorize('void(float64[:], ...
Read more >
[Numba] guvectorize with fixed size output array?
Is it possible to guvectorize this? ... ValueError: bad token in signature "6" ... signature, but have not invested any major effort there...
Read more >
Returning an array of 3D or 6D vectors from `guvectorize` on ...
from numba import guvectorize, jit, cuda import numpy as np TARGET ... numba to fail to compile: ValueError: bad token in signature "3"....
Read more >
用户对问题“使用numba & @guvectorize''Bad in signature'”的回答
我正在尝试用一个输出m,2数组的函数来装饰@guvectorize。 ... raise ValueError('bad token in signature "%s"' % tok[1]) ValueError: bad token in signature "2"
Read more >
numba.guvectorize Example - Program Talk
Learn how to use python api numba.guvectorize. ... assertIn("bad token in signature", str(raises.exception)) # Output shape can't be inferred from inputs ...
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