Repository navigation
Closed
Milestone
Description
Description
ArkoudaArray currently supports arithmetic and comparison operations primarily through explicit functions and operator implementations at the pandas/Series level, but it does not fully expose Python dunder operator methods (e.g. __add__, __radd__, __eq__, etc.) directly on the array object.
This gap causes:
- Inconsistent behavior between
ArkoudaArrayand NumPy/pandas array semantics - Surprising failures for expressions that rely on Python’s operator dispatch (e.g. chained expressions, unary operators, reverse operators)
- Extra complexity in higher-level code that assumes array-like objects implement standard dunder methods
Adding these methods will improve correctness, ergonomics, and compatibility with pandas-style operations and user expectations.
Scope / Proposed Changes
Implement the following categories of dunder methods on ArkoudaArray, delegating to existing Arkouda operations where possible:
Arithmetic
__add__,__sub__,__mul__,__truediv__,__floordiv__,__mod__,__pow__- Reverse operators:
__radd__,__rsub__, etc. - Unary operators:
__neg__,__pos__,__abs__
Comparisons
__eq__,__ne__,__lt__,__le__,__gt__,__ge__
Logical / Bitwise (where supported by dtype)
__and__,__or__,__xor__- Reverse variants as appropriate
Design Notes
- Methods should follow NumPy/pandas semantics for scalar vs array operands and broadcasting.
- Where Arkouda server-side constraints apply (e.g. dtype matching), behavior should be explicit and documented.
- Unsupported dtype/operator combinations should raise clear, consistent exceptions.
- Reverse operators should ensure correct dispatch when the left operand is a Python scalar or NumPy object.
Testing
- Add unit tests covering:
- Array–array operations
- Array–scalar and scalar–array operations
- Unary operators
- Comparison operators
- Error cases (unsupported dtypes, invalid operations)
- Where applicable, include equivalency tests against NumPy or pandas behavior.
Acceptance Criteria
- Standard Python operators work directly on
ArkoudaArrayinstances - Behavior is consistent with existing Arkouda functions and pandas expectations
- No regressions in existing arithmetic or comparison functionality
- Tests clearly demonstrate correct operator dispatch and error handling
Metadata
Metadata
Assignees
Labels
No labels
Activity
Closes Bears-R-Us#5380: Add Python dunder operator methods to Arkouda…
Closes Bears-R-Us#5380: Add Python dunder operator methods to Arkouda…
Closes Bears-R-Us#5380: Add Python dunder operator methods to Arkouda…
Closes Bears-R-Us#5380: Add Python dunder operator methods to Arkouda…
Closes Bears-R-Us#5380: Add Python dunder operator methods to Arkouda…
Closes Bears-R-Us#5380: Add Python dunder operator methods to Arkouda…
Closes Bears-R-Us#5380: Add Python dunder operator methods to Arkouda…
Closes Bears-R-Us#5380: Add Python dunder operator methods to Arkouda…
Closes #5380 add python dunder operator methods to arkouda array (#5381)