Skip to content

Closes #5308: Improve ArkoudaExtensionArray._reduce - #5309

Merged
ajpotts merged 2 commits into
Bears-R-Us:mainfrom
ajpotts:5308_Improve_ArkoudaExtensionArray._reduce
Jan 22, 2026
Merged

ajpotts merged 2 commits into
Bears-R-Us:mainfrom
ajpotts:5308_Improve_ArkoudaExtensionArray._reduce

Conversation

@ajpotts

@ajpotts ajpotts commented Jan 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR modernizes the ArkoudaArray._reduce implementation to better align with
pandas ExtensionArray semantics, and significantly expands unit test coverage for reduction behavior.

Key goals of this change:

  • Make _reduce string-driven, matching pandas’ calling conventions
  • Support a broader, well-defined set of reductions
  • Improve error reporting and dtype validation
  • Add comprehensive tests covering correctness, edge cases, and failure modes

Changes

ArkoudaArray._reduce

  • Replaced ad-hoc conditional logic with a structured dispatch table
  • Added support for:
    • Numeric reductions: sum, prod, min, max, mean, var, std
    • Index reductions: argmin, argmax, first
    • Boolean reductions: any, all, or, and (with dtype enforcement)
    • Count via array size / non-NaN count for floats
    • Mode (array-returning reduction)
  • Improved error handling:
    • Unknown reduction names raise ValueError
    • Unsupported reductions or dtype mismatches raise TypeError
  • Added full type hints and a darglint-compliant docstring

GroupByReductionType

  • Fixed a typo: NUNUNIQUE → NUNIQUE

Tests

  • Replaced minimal smoke tests with a dedicated TestArkoudaArrayReduce suite
  • Added tests for:
    • Numeric reductions vs NumPy
    • Boolean reductions and dtype validation
    • count, argmin, argmax, and first
    • Empty-array edge cases
    • Unknown reduction names
    • Acceptance of the skipna argument
  • Removed outdated tests that expected "mean" to be unsupported

Rationale

_reduce is part of the pandas ExtensionArray protocol and is invoked directly
by pandas using string operation names.

The expanded test coverage ensures correctness, documents intended semantics,
and provides a stable foundation for adding future reductions (e.g., median,
unique, nunique) as backend support evolves.


Notes for Reviewers

  • This PR does not change public pandas-facing APIs, only internal behavior
  • Reduction semantics intentionally mirror NumPy/pandas where possible
  • Follow-up PRs may add capability-gated reductions as Arkouda support expands

Closes #5308: Improve ArkoudaExtensionArray._reduce

@ajpotts
ajpotts force-pushed the 5308_Improve_ArkoudaExtensionArray._reduce branch from ccea726 to 6bb3eff Compare January 12, 2026 23:29
@ajpotts
ajpotts force-pushed the 5308_Improve_ArkoudaExtensionArray._reduce branch 2 times, most recently from a899478 to 955716b Compare January 13, 2026 14:40
@ajpotts
ajpotts force-pushed the 5308_Improve_ArkoudaExtensionArray._reduce branch from 955716b to 38e739c Compare January 13, 2026 18:32
@ajpotts
ajpotts marked this pull request as ready for review January 13, 2026 19:29
@codecov-commenter

codecov-commenter commented Jan 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@be6b999). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #5309   +/-   ##
========================================
  Coverage        ?   100.00%           
========================================
  Files           ?         4           
  Lines           ?        63           
  Branches        ?         0           
========================================
  Hits            ?        63           
  Misses          ?         0           
  Partials        ?         0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ajpotts
ajpotts force-pushed the 5308_Improve_ArkoudaExtensionArray._reduce branch from 38e739c to e630a71 Compare January 16, 2026 15:20
@ajpotts
ajpotts marked this pull request as draft January 16, 2026 15:22
@ajpotts
ajpotts force-pushed the 5308_Improve_ArkoudaExtensionArray._reduce branch from e630a71 to fa3c74c Compare January 16, 2026 16:19
@ajpotts
ajpotts force-pushed the 5308_Improve_ArkoudaExtensionArray._reduce branch from fa3c74c to 91564d8 Compare January 16, 2026 16:20
@ajpotts
ajpotts marked this pull request as ready for review January 16, 2026 16:20

@1RyanK 1RyanK left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

@ajpotts ajpotts added the blocking This is blocking a developer from completing a task they are actively working. label Jan 16, 2026
@ajpotts
ajpotts force-pushed the 5308_Improve_ArkoudaExtensionArray._reduce branch from 9c51836 to 4d84262 Compare January 16, 2026 21:29
@ajpotts
ajpotts force-pushed the 5308_Improve_ArkoudaExtensionArray._reduce branch from 4d84262 to f74f6c6 Compare January 16, 2026 21:33

@jaketrookman jaketrookman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good

@ajpotts
ajpotts added this pull request to the merge queue Jan 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 21, 2026
@ajpotts
ajpotts added this pull request to the merge queue Jan 22, 2026
Merged via the queue into Bears-R-Us:main with commit a449c14 Jan 22, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocking This is blocking a developer from completing a task they are actively working.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve ArkoudaExtensionArray._reduce

4 participants