Skip to content
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

Add Unary Operator Support to PintArrays #221

Closed
Nick-Hemenway opened this issue Apr 3, 2024 · 1 comment · Fixed by #160
Closed

Add Unary Operator Support to PintArrays #221

Nick-Hemenway opened this issue Apr 3, 2024 · 1 comment · Fixed by #160

Comments

@Nick-Hemenway
Copy link
Contributor

Currently the below example does not work:

from pint_pandas import PintArray

p = PintArray(np.array([1,2,3], dtype=np.float64), 'm')
p1 = -p

Instead you must multiply by a negative scalar as follows:

p1 = -1*p
@andrewgsavage
Copy link
Collaborator

andrewgsavage commented Apr 3, 2024

I had hoped to get this working with #160 , but that's still a while off...

Alternatively PintArray.__pos__ and PintArray.__neg__ could be implemented for -p and -p .
The unary tests in #160 can be copied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants