-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat: Implement/fix unary minus operator -pl.col(...)
#13776
Conversation
72aa951
to
ff8b130
Compare
One thing I would like to note is that overflow on negation isn't unique to the unsigned types. E.g. for >>> pl.Series([-1, -128], dtype=pl.Int8)
shape: (2,)
Series: '' [i8]
[
-1
-128
]
>>> -_
shape: (2,)
Series: '' [i8]
[
1
-128
] |
ff8b130
to
38c47df
Compare
I'm aware of this. In this PR it panicks with the message "attempt to negate with overflow" - there's a test for this. I think that behavior is fine as it is only the lower bound value that causes problems. |
c90dc76
to
f6ba1a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great addition @stinodego. This primitive was long overdue.
One rebase away.... |
f6ba1a2
to
abae861
Compare
Rebased 👍 I just want to note that this does break any workflow that relied on doing |
I consider it a fix. The previous behavior was unintentional. |
Closes #6192
Changes
Neg
operator in Rust, dispatch to it from Python__pos__
into a no-opPoint of discussion: for unsigned integers, should we raise (like now) or should we cast it to some supertype, e.g. cast
UInt8
toInt16
?