Improving the error message when adding i8 array to u8 array
See original GitHub issueWhen attempting to add an ndarray
of type int64
to an ndarray
of type uint64
, numpy
throws a TypeError
:
TypeError: Cannot cast ufunc add output from dtype('float64') to dtype('uint64') with casting rule 'same_kind'
The error message incorrectly identifies the type of the first array as float64
, when it is actually int64
.
Reproducing code example:
import numpy as np
x = np.arange(5, dtype='u8')
y = np.arange(5, dtype='i8')
x += y
Error message:
TypeError: Cannot cast ufunc add output from dtype('float64') to dtype('uint64') with casting rule 'same_kind'
Numpy/Python version information:
Tested with Python 3:
1.16.4 3.6.8 (default, Oct 7 2019, 12:59:55)
[GCC 8.3.0]
Also with Python 2:
('1.15.1', '2.7.15+ (default, Oct 7 2019, 17:39:04) \n[GCC 7.4.0]')
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Error to append a converted u8 (from i8) to an ArrayList, only ...
This has nothing to do with the intCast, the issue is that the function's return type does not allow for a possible error...
Read more >How to convert &[i8] to &[u8]? - Rust Users Forum
I tried to use let u8slice : &[u8] = i8slice as &[u8]; But it complains an as expression can only be used to...
Read more >Arrays and pointers questions - Xilinx Support
I'm getting errors when trying to synthesize, such as unsupported pointer reinterpretation from type 'i16*' to type 'i8*' when casting ...
Read more >TypedArray - JavaScript - MDN Web Docs
A TypedArray object describes an array-like view of an underlying binary data buffer. There is no global property named TypedArray, ...
Read more >LLVM Language Reference Manual
Scalable vectors cannot be global variables or members of arrays because ... be placed into special subsection of the text section to improving...
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
Let’s wait and see if any progress is made on #14843
Hi @5aumy4, welcome. As with many of these issues, it turns out to be more difficult than a simple error message change. See gh-14843.
As for getting started, you can read our contribution guide