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.

np.full ignores keyword argument names

See original GitHub issue

In 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:closed
  • Created a year ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
stuartarchibaldcommented, Apr 14, 2022

Stuart, does it make sense to start migrating old code to use overload, instead of attempt to fix the “overload glue” part?

@guilhermeleobas Probably something for discussion at the next triage meeting? I’ve got a patch that migrates np.empty, np.zeros and np.ones already. 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.

0reactions
stuartarchibaldcommented, Apr 20, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

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