Repository navigation
Closes #5111: numpy operations alignment tests - #5121
Merged
ajpotts merged 2 commits intoDec 22, 2025
Merged
Conversation
ajpotts
force-pushed
the
5111_numpy_operations_alignment_tests
branch
from
December 16, 2025 22:45
3b67ec8 to
49cac3c
Compare
ajpotts
marked this pull request as ready for review
December 17, 2025 12:24
1RyanK
approved these changes
Dec 17, 2025
ajpotts
force-pushed
the
5111_numpy_operations_alignment_tests
branch
from
December 18, 2025 22:25
49cac3c to
54cba3f
Compare
ajpotts
added a commit
that referenced
this pull request
Dec 18, 2025
…ics (#5124) 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 Co-authored-by: ajpotts <[email protected]>
ajpotts
force-pushed
the
5111_numpy_operations_alignment_tests
branch
from
December 19, 2025 11:37
9255553 to
13def6f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR: Add Comprehensive NumPy-Alignment Test Suite for Unary, Binary, and Comparison Operators
This PR introduces a complete NumPy-alignment test suite for Arkouda’s
pdarrayoperator semantics.It adds a new test module:
and registers it in
pytest.ini, ensuring it runs as part of the standard NumPy compatibility test suite.What This PR Does
1. Adds a full operator-alignment test suite
The new module tests:
Binary arithmetic operators
+,-,*,/,//,%,**<<,>>,&,|,^Scalar broadcasting
array ⊗ scalarscalar ⊗ arrayComparison operators
==,!=,<,<=,>,>=Unary operators
+a(pos)-a(neg)~a(invert)This suite validates that Arkouda’s operator implementations match NumPy semantics exactly across
int64,uint64,float64, andbool_dtypes.Key capabilities tested
Accurate dtype handling
truediv, exponent ranges, invert not allowed)uint64andint64power and shift constraintsShift and power safety
The suite constrains RHS values for operators like:
pow(limits exponent size)lshift/rshift(enforces nonnegative RHS)NumPy-equivalent error handling
Some operations are skipped when NumPy does not support them, ensuring test intent matches NumPy’s behavior.
File Changes
pytest.ini
Adds the new module to Arkouda’s NumPy test paths.
tests/numpy/alignment_verification/operators_alignment.py
A 227‑line comprehensive alignment suite covering:
✔ Why This Is Important
This suite provides Arkouda with:
1. A single source of truth for NumPy operator semantics
All operator behavior is now validated rigorously and uniformly.
2. A foundation for correcting bugs
The suite already uncovered several issues:
rshift(int64)uint64negation behaviorpow(scalar, array)3. A roadmap for missing operator coverage
The test suite makes gaps visible, e.g.:
__pos____abs__4. Reproducibility
All tests use deterministic PRNG behavior (
SEED = 314159).Follow-Up Work (Suggested)
__pos__,__abs__,divmod, in-place ops, etc.)Summary
This PR significantly strengthens Arkouda’s NumPy compatibility guarantees by adding a comprehensive, easy‑to‑extend test suite that verifies operator semantics end‑to‑end across all supported dtypes.
It lays the groundwork for aligning Arkouda more closely with NumPy behavior and making operator support more predictable, correct, and testable.
Closes #5111: numpy operations alignment tests