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.

guvectorize does not implement the numpy ufunc interface in versions 0.53+

See original GitHub issue

Hi, after upgrading numba from version 0.52.0 to either versions 0.53.0 or 0.54.0, I have found that the signature field of functions compiled using @guvectorize no longer is implemented.

Tested with: numpy version 1.20.0 numba version 0.52.0, 0.53.0, 0.54.0

Here is a minimal working example:

from numba import guvectorize

@guvectorize(["void(float64[:], float64[:], float64[:])"],
             "(n),(n)->()", nopython=True, cache=True)
def test(a, b, c):
    c[0]=0
    for i in range(len(a)):
        c[0] += a[i]*b[i]

When I try using this, here’s what happens with 0.52.0:

In [1]: import test_gufunc                                                      

In [2]: test_gufunc.test.signature                                              
Out[2]: '(n),(n)->()'

And here’s what I get with the newer versions:

In [1]: import test_gufunc                                                      

In [2]: test_gufunc.test.signature                                              
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-d4d284438f75> in <module>
----> 1 test_gufunc.test.signature

AttributeError: 'GUFunc' object has no attribute 'signature'

Reporting a bug

  • I have tried using the latest released version of Numba (most recent is visible in the change log (https://github.com/numba/numba/blob/master/CHANGE_LOG).
  • I have included a self contained code sample to reproduce the problem. i.e. it’s possible to run as ‘python bug.py’.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
iguinncommented, Nov 24, 2021

Thanks for fixing this! I’ll be looking forward to the next release.

0reactions
guilhermeleobascommented, Sep 15, 2021

Hi @gmarkall, yes, that’s possible. I’ll send a PR shortly. @iguinn, thanks for reporting this bug!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating NumPy universal functions - Numba documentation
Numba's vectorize allows Python functions taking scalar input arguments to be used as NumPy ufuncs. Creating a traditional NumPy ufunc is not the...
Read more >
Numba guvectorize exception due to Numpy ufunc signature
I understand the purpose of the algorithm is to obtain the average of a vector's slice. For example, having vector [1,2,3,4,5] and slice...
Read more >
guvectorize returns different output after upgrading to Numpy ...
When using the new dynamic typing in Numba 0.53 it always works correctly, regardless whether the output array is np.uint8 or np.int8 ....
Read more >
Enhancements to Numba's guvectorize decorator
In NumPy, it is fine to omit the output argument when calling a generalized ufunc. ... The same is not possible in a...
Read more >
numpy.ufunc.reduce — NumPy v1.23 Manual
New in version 1.7.0. initialscalar, optional. The value with which to start the reduction. If the ufunc has no identity or the dtype...
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