Skip to content

Add Python dunder operator methods to ArkoudaArray #5380

Closed

Description

@ajpotts

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 ArkoudaArray and 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 ArkoudaArray instances
  • 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

Activity

  1. self-assigned this
    on Feb 2, 2026
  2. added 8 commits that reference this issue on Feb 2, 2026
    17725cc
    ed38218
    67237b2
    4e6444b
    784509b
    adedff2
    7d8ee37
    d440602
  3. added a commit that references this issue on Feb 11, 2026
    4b5fad5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions