numba.typed.typeddict.Dict.get returns the default even though the key is present
See original GitHub issueWith some specific key dtypes, Dict.get returns the default value even when the key is present. This has been tested with numba 0.55.1
To reproduce:
import numba
numba_dict = numba.typed.typeddict.Dict.empty(
key_type=numba.types.Tuple([numba.types.uint32, numba.types.uint32]),
value_type=numba.types.int64)
numba_dict[(1,1)] = 12345
assert numba_dict.get((1,1), 1) == numba_dict[(1,1)]
The error depends on the size of the ints in the key, not on the unsigned aspect. It disappears with e.g. numba.types.Tuple([numba.types.uint32, numba.types.uint64])
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Supported Python features - Numba
Numba supports function calls using positional and named arguments, as well as arguments with default values and *args (note the argument for *args...
Read more >Using Dictionaries with numba njit function - Stack Overflow
Now I have a function that accepts and returns dictionaries. How can I apply numba here? def collocation(aeolus_data,val_data): ... return ...
Read more >SystemError potentially from Typed Dict - Numba Discussion
Therefore, I updated VTK 6.3 to VTK 7.1 and noticed that mentions of Python 3.8 (default on Ubuntu 20.04) were now present in...
Read more >numba/numba - Gitter
mydict = nb.typed.Dict.empty( key_type=nb.types.UniTuple(nb.int64,2), value_type=nb.typeof(np.ones(2))) #I set a len==2 array mydict[(1,2)] = np.ones(2) #I ...
Read more >alphapept - FASTA - GitHub Pages
Returns : list (of str): cleaved peptide sequences with missed cleavages. ... List, mass_dict:numba.typed.typeddict.Dict). Get neutral peptide mass, ...
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 Thanks for debugging, your assessment in https://github.com/numba/numba/issues/7908#issuecomment-1068327361 seems to highlight the likely cause.
@czgdp1807 RE the warning:
This is because the dictionary is declared as taking
uint32but Numba will infer the type of a Python int asint64, as a result the type of the requested keyUniTuple(int64 x 2)has to be cast to match the types of the keys as declared in the dictionary. This is expected.Patches to fix and test as suggested are welcome. Many thanks!
Great. I will send a fix with a regression test tomorrow.