-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Wrong error message for "+" (add) operation about "use np.concontenate() instead" for scalar with array priority #18832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Interesting, Python allows this to drop through to concatenation even though both operators define normal addition (even though both operators define normal addition). I am not sure that is quite correct on the Python side, but I guess that doesn't really matter. I can't really think of a solution right now. We may just have to delete that whole code path again, if it is accessible through the normal |
Do you mean what was added in #16570? |
Bah, this is all super awkward... Yes, I mean that PR, in the end I am not invested in keeping that PR around. I think that But... At the same time pandas is sligthly breaking the "assymetry of binary operands" contract (which is very arcane!). Basically To proof my point, try this:
In the first case it is OK that you defer to NumPy. NumPy realize its (Long story short, I won't complain about undoing the PR to get the old TypeError back, but I am not quite sure its actually the best outcome for either project.) |
This happened to me because I forgot to convert a torch tensor to numpy. Basically in this scenario:
Error:
This was quite confusing to debug because I used assignment to a slice where I've combined scatter on one dimension and bool mask on other dimension and LLMs would tell me the problem is with my indexing... |
Reproducing code example:
So for
datetime.datetime
object, this gives the expected TypeError. But forpd.Timestamp
it gives a confusing error message.I suppose the difference could stem from the fact that
pd.Timestamp
defines an__array_priority__
. However, in this case it just returnsNotImplemented
when passed a float ndarray, so I would still expect to get the normal "unsupported operand type" TypeError.(opening the issue here in numpy because the error message comes from numpy; of course it might also be that we need to change something in
Timestamp.__add__
, although as said above, it's returningNotImplemented
in this case)NumPy/Python version information:
The text was updated successfully, but these errors were encountered: