np.full ignores keyword argument names
See original GitHub issueIn np.full, numba ignores the named keyword arguments.
import numba
import numpy as np
@numba.jit(nopython=True)
def test1():
x = np.full(shape=123, fill_value=456)
print(x.shape)
@numba.jit(nopython=True)
def test2():
x = np.full(fill_value=456, shape=123)
print(x.shape)
test1()
test2()
outputs
(123,)
(456,) # WRONG! The shape is given as `shape=123` in the function call!
Bug
Both test1 and test2 would be interpereted the same by numpy alone. The only difference between them is the order of the keyword arguments fill_value and shape. Numba seems to silently ignore this order. I am not sure this is a bug, but this just cost me nearly one hour of debugging. (I am still a very happy Numba user)
Numba version
numba 0.55.1
- I have tried using the latest released version of Numba (most recent is visible in the change log (https://github.com/numba/numba/blob/main/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:
- Created a year ago
- Comments:11 (9 by maintainers)
Top Results From Across the Web
How does one ignore unexpected keyword arguments passed ...
The most important thing you can do with the second that you can't do with the first is take a as a positional...
Read more >Accepting arbitrary keyword arguments in Python
Let's make a function that accepts arbitrary keyword arguments. Calling with arbitrary keyword arguments. We're going to make a function ...
Read more >What's new in 1.4.0 (January 22, 2022) - Pandas
The keyword arguments level and names have been added to Styler.hide() (and implicitly to the deprecated methods Styler.hide_index() and ...
Read more >Reference — iminuit 1.5.4 documentation
Keyword arguments are forwarded to matrix() . The name of this function was chosen to be analogous to matrix() , it returns the...
Read more >Built-in Functions — Python 3.11.1 documentation
The instance is ignored except for its class. If a class method is called for a derived class, the derived class object is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@guilhermeleobas Probably something for discussion at the next triage meeting? I’ve got a patch that migrates
np.empty,np.zerosandnp.onesalready. Translating these functions is quite a detail heavy task but potentially a better place to spend effort. I would hope once the common translation patterns become clear it can progress reasonably quickly and the shim code can be removed.I’ve got a WIP patch to fix here https://github.com/numba/numba/pull/7996, needs some work to clean it up but as this is both a regression and a mis-compile, it’s going to be fixed for the upcoming 0.56 release.