Skip to content

Conversation

@ajpotts
Copy link
Contributor

@ajpotts ajpotts commented Jan 6, 2026

Expand ArkoudaArray._reduce to support full reduction set

Summary

This PR significantly expands the internal ArkoudaArray._reduce implementation to support a broad, pandas-compatible set of reduction operations, and adds comprehensive tests covering both functionality and argument handling.

The new implementation replaces a hard-coded conditional chain with a centralized, extensible dispatch table and introduces robust argument passthrough logic that safely forwards only supported keyword arguments to backend methods.

Key Changes

ArkoudaArray._reduce

  • Accepts reduction names as either str or GroupByReductionType
  • Centralizes reduction dispatch via a mapping table
  • Delegates to backend methods when available, with clear error reporting otherwise
  • Filters keyword arguments (skipna, ddof, etc.) based on backend method signatures
  • Adds full type annotations and NumPy-style docstring sections (Parameters, Returns, Raises)

Supported reductions include:

  • Numeric / boolean: all, any, sum, prod, min, max, mean, var, std, count, nunique, first
  • Index-returning: argmin, argmax
  • Planned / backend-dependent: median, mode, unique, or, and, xor

Reductions not implemented by the underlying Arkouda backend raise a clear TypeError.

Test Coverage

The test suite for ArkoudaArray reductions has been substantially expanded:

  • Scalar reductions: verifies correct return types for all supported numeric/boolean reductions
  • Argument reductions: validates argmin / argmax semantics
  • Array-returning reductions: covers unique and mode
  • Boolean reductions: covers or, and, xor for boolean arrays
  • Keyword argument handling:
    • skipna passthrough behavior
    • ddof passthrough for var / std when supported
    • Graceful ignoring of unsupported keyword arguments

Tests automatically xfail when a reduction is not implemented by the current Arkouda backend, ensuring CI stability while preserving visibility into planned functionality.

Motivation

This change moves _reduce closer to pandas ExtensionArray expectations, reduces duplication, and provides a clear framework for incrementally adding backend support for additional reductions.

It also improves developer ergonomics by making reduction support explicit, discoverable, and well-tested.

Closes #5232: _reduce improvements for ArkoudaExtensionArray

@ajpotts ajpotts force-pushed the 5232_reduce_improvements_for_ArkoudaExtensionArray branch from 984a867 to 5d0e513 Compare January 6, 2026 18:02
@ajpotts ajpotts marked this pull request as ready for review January 6, 2026 21:13
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.

_reduce improvements for ArkoudaExtensionArray

1 participant