Skip to content

Closes #5117: Unary Negation on ak.uint64 Does Not Match Numpy Semantics - #5124

Merged
ajpotts merged 2 commits into
Bears-R-Us:mainfrom
1RyanK:5117-Unary_Negation_on_ak_uint64_Does_Not_Match_Numpy_Semantics
Dec 18, 2025
Merged

ajpotts merged 2 commits into
Bears-R-Us:mainfrom
1RyanK:5117-Unary_Negation_on_ak_uint64_Does_Not_Match_Numpy_Semantics

Conversation

@1RyanK

@1RyanK 1RyanK commented Dec 5, 2025

Copy link
Copy Markdown
Contributor

Since both of these are unary operators and in light of the testing framework in PR #5121, I thought I would bundle both the negation changes for uint64 and bool together.

For unary negation on uint64, twos complement suggests that the way to handle this is to negate the bits and add 1.

For unary negation on bool, the solution suggested was to raise a TypeError and suggest using ~ instead or logical_not, but since logical_not did not exist, I added it and have it pointing at ~ since they seem to largely be the same thing. I think additional tests specific to logical_not would be unnecessary if ~ is being tested because it's literally a wrapper for ~. However, I did grab the unit tests from PR #5121 that seem relevant to this PR.

Closes #5117: Unary Negation on ak.uint64 Does Not Match Numpy Semantics
Closes #5119: Bug: Unary Negation (-a) on ak.bool_ Does Not Match NumPy Semantics

@1RyanK
1RyanK force-pushed the 5117-Unary_Negation_on_ak_uint64_Does_Not_Match_Numpy_Semantics branch from bb417a4 to f2dd364 Compare December 5, 2025 16:25
@1RyanK
1RyanK force-pushed the 5117-Unary_Negation_on_ak_uint64_Does_Not_Match_Numpy_Semantics branch 2 times, most recently from bd5805c to 5c55e5b Compare December 5, 2025 19:57
@1RyanK
1RyanK marked this pull request as ready for review December 8, 2025 12:13

@ajpotts ajpotts left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, but I think we should include the scalar case to align with NumPy.

Comment thread arkouda/numpy/pdarrayclass.py Resolved
@1RyanK
1RyanK force-pushed the 5117-Unary_Negation_on_ak_uint64_Does_Not_Match_Numpy_Semantics branch 5 times, most recently from 039d92a to 927fab9 Compare December 14, 2025 21:36
@1RyanK
1RyanK force-pushed the 5117-Unary_Negation_on_ak_uint64_Does_Not_Match_Numpy_Semantics branch from 927fab9 to a4cb7e3 Compare December 16, 2025 16:52

@drculhane drculhane left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the looks of the operators_alignment.py, you have more in mind for this. As is, it looks good.

@1RyanK

1RyanK commented Dec 16, 2025

Copy link
Copy Markdown
Contributor Author

From the looks of the operators_alignment.py, you have more in mind for this. As is, it looks good.

It's mostly just ripped out from the relevant parts of #5121

Comment thread arkouda/numpy/pdarrayclass.py Resolved
@1RyanK
1RyanK force-pushed the 5117-Unary_Negation_on_ak_uint64_Does_Not_Match_Numpy_Semantics branch from 5ab7753 to a41e98e Compare December 17, 2025 14:13
@ajpotts
ajpotts enabled auto-merge December 18, 2025 22:45
@ajpotts
ajpotts disabled auto-merge December 18, 2025 23:29
@ajpotts
ajpotts merged commit 2970c70 into Bears-R-Us:main Dec 18, 2025
github-merge-queue Bot pushed a commit that referenced this pull request Dec 22, 2025
… in Arkouda (#5126)

Very straightforward, ~~but wait until PR #5124 to merge first.~~

PR #5214 has been merged in so this one is good to go!

Closes #5116: Feature Request: Implement pdarray.__pos__ (Unary Plus) in
Arkouda
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 this pull request may close these issues.

Bug: Unary Negation (-a) on ak.bool_ Does Not Match NumPy Semantics Bug: Unary Negation (-a) on ak.uint64 Does Not Match NumPy Semantics

3 participants