Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImproving the error message when adding i8 array to u8 array #14828
Comments
That would be true if the message said "Cannot cast ufunc add input", but it actually uses the word "output". The meaning here is that the output performed by Can you suggest a clearer error message? The code that generates it is here: numpy/numpy/core/_exceptions.py Lines 108 to 116 in 463acda |
Okay, I hadn't appreciated the mechanics of what's going on behind the scenes with For this particular problem, something like
would be more informative, but it's a much more specific error message that wouldn't work for all ufunc functions. |
That seems like a pretty reasonable suggestion - note that in order to get the extra dtype information, you (or whoever wants to improve this) would need to modify these lines too: numpy/numpy/core/src/umath/ufunc_type_resolution.c Lines 246 to 252 in 7b8513f With that in mind, most of the exceptions would probably want to change in the same way - but that's fine, they're not public API thanks to Another possible wording:
or even
where the former types are |
I want to work on this. |
There's already a PR for this, but it seems we forgot to link it... |
Is this issue still active? If yes I would like to take this up. @eric-wieser |
Let's wait and see if any progress is made on #14843 |
When attempting to add an
ndarray
of typeint64
to anndarray
of typeuint64
,numpy
throws aTypeError
:The error message incorrectly identifies the type of the first array as
float64
, when it is actuallyint64
.Reproducing code example:
Error message:
Numpy/Python version information:
Tested with Python 3:
Also with Python 2: