Skip to content

Conversation

@ajpotts
Copy link
Contributor

@ajpotts ajpotts commented Feb 12, 2026

Summary

This PR implements the pandas ExtensionArray comparison protocol for
ArkoudaArray by adding a fully-typed _cmp_method implementation and
expanding comparison test coverage.

This resolves issues where operations such as:

x = pd.array([1, 3, 4, 1], dtype="ak_int64")
x > 2

would fail due to missing or incorrectly scoped helper methods.


Changes

1. Implement _cmp_method

  • Added _cmp_method to conform to pandas ExtensionArray API.
  • Properly typed with full signature annotations.
  • Returns ArkoudaArray | NotImplementedType.
  • Delegates to _binary_op to reuse normalization and broadcasting
    logic.
  • Fully documented with NumPy-style docstring compliant with
    pydoclint.

2. Harden _coerce_other_for_binop

  • Added explicit return type annotation tuple[Any, str].
  • Updated docstring to match signature (fixes DOC101, DOC103, DOC203).
  • Removed unnecessary comment for clarity.

3. Add Comparison Test Coverage

New tests added to tests/pandas/extension/arkouda_array_extension.py:

  • _cmp_method matches dunder operators
  • Scalar comparisons
  • NumPy array comparisons
  • Length mismatch raises ValueError
  • Guard test ensuring helper methods exist (prevents indentation
    errors)
  • pd.array(..., dtype="ak_int64") > scalar integration test

These tests prevent regression of the original failure mode
(AttributeError: 'ArkoudaArray' object has no attribute '_coerce_other_for_binop').


Why This Matters

  • Ensures full compatibility with pandas comparison dispatch.
  • Prevents silent class-structure regressions (indentation/dedent
    issues).
  • Improves test coverage for comparison operations.
  • Brings docstrings into full compliance with project linting rules.

Validation

  • flake8 passes (including pydoclint rules).
  • All new comparison tests pass.
  • Manual verification of pd.array(..., dtype="ak_int64") > scalar.

Closes #5404: ArkoudaExtensionArray._cmp_method

@ajpotts ajpotts force-pushed the 5404_ArkoudaExtensionArray._cmp_method branch from 705adb5 to 326f2d6 Compare February 12, 2026 11:59
@ajpotts ajpotts marked this pull request as ready for review February 12, 2026 13:04
Copy link
Contributor

@jaketrookman jaketrookman left a comment

Choose a reason for hiding this comment

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

Looks good

@ajpotts ajpotts merged commit 75b6321 into Bears-R-Us:main Feb 12, 2026
19 checks passed
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.

ArkoudaExtensionArray._cmp_method

2 participants