Skip to content

Closes #5105: ArkoudaExtensionArray.__getitem__ - #5106

Merged
ajpotts merged 5 commits into
Bears-R-Us:mainfrom
ajpotts:5105_ArkoudaExtensionArray_getitem
Jan 28, 2026
Merged

ajpotts merged 5 commits into
Bears-R-Us:mainfrom
ajpotts:5105_ArkoudaExtensionArray_getitem

Conversation

@ajpotts

@ajpotts ajpotts commented Dec 3, 2025 •

Copy link
Copy Markdown
Contributor

PR: Unified Indexing & Assignment for Arkouda Extension Arrays

This PR introduces a complete overhaul of __getitem__ and __setitem__ across all Arkouda-backed pandas ExtensionArray types:

  • ArkoudaArray
  • ArkoudaStringArray
  • ArkoudaCategoricalArray

The goal is to bring these classes into full alignment with pandas/NumPy indexing rules, while ensuring all operations are executed entirely on the Arkouda server (no unintended materialization, no to_numpy() or to_ndarray() inside assignment paths).


Summary of Changes

⭐ 1. Unified Indexer Normalization

All extension arrays now normalize Python / NumPy indexers the same way:

  • int, slice: forwarded directly to the underlying Arkouda object
  • NumPy integer arrays → ak.array(..., dtype=int64/uint64)
  • NumPy boolean masks → ak.array(..., dtype=bool)
  • Python lists of ints/bools → ak.array(...)
  • Arkouda pdarray indexers pass through unchanged
  • Empty indexers ([], np.array([], ...)) return an empty array of the same type

This ensures consistency across array types and avoids breaking pandas’ internal indexing machinery.


⭐ 2. New __getitem__ Implementations

ArkoudaArray

  • Mirrors pandas EA semantics exactly.
  • Returns a Python scalar for integer indexing and a new ArkoudaArray for everything else.
  • Full rewrite with examples and proper Raises section.
  • Now fully matches ExtensionArray.__getitem__ type signature.

ArkoudaStringArray

  • Correctly distinguishes scalar vs non-scalar returns.
  • Ensures doctest examples return object dtype arrays when round-tripped through NumPy.
  • Handles all indexer forms without falling through to unsupported Arkouda paths.

ArkoudaCategoricalArray

  • Returns a scalar Python string for scalar access and a wrapped categorical EA otherwise.
  • Empty indexers produce an empty categorical of type str_.

Closes #5105: ArkoudaExtensionArray.getitem

@ajpotts
ajpotts force-pushed the 5105_ArkoudaExtensionArray_getitem branch from 4ed7c8b to 27a4bef Compare December 3, 2025 21:22
@ajpotts
ajpotts marked this pull request as ready for review December 5, 2025 11:45

@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 force-pushed the 5105_ArkoudaExtensionArray_getitem branch from 27a4bef to 78de756 Compare December 15, 2025 21:57
@ajpotts
ajpotts force-pushed the 5105_ArkoudaExtensionArray_getitem branch from 7e7c2f3 to 8fabbbb Compare December 29, 2025 18:38
@ajpotts
ajpotts force-pushed the 5105_ArkoudaExtensionArray_getitem branch from 8fabbbb to b50789d Compare January 13, 2026 19:43
@codecov

codecov Bot 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@f7bef63). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #5106   +/-   ##
========================================
  Coverage        ?   100.00%           
========================================
  Files           ?         5           
  Lines           ?       109           
  Branches        ?         0           
========================================
  Hits            ?       109           
  Misses          ?         0           
  Partials        ?         0           
Flag Coverage Δ
python-coverage 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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 5105_ArkoudaExtensionArray_getitem branch from b50789d to a20ae1f Compare January 16, 2026 17:28
@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 5105_ArkoudaExtensionArray_getitem branch 2 times, most recently from 7d55305 to 1b171e0 Compare January 23, 2026 13:04

@drculhane drculhane 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.

First observation.

There are test_getitem tests in both the TestArkoudaArrayExtension and TestArkoudaArrayGetitem classes.

Similarly, there are test_setitem tests in both the TestArkoudaArrayExtension and TestArkoudaArraySetitem classes.

This looks like the intent had been to put all the getitem tests into TestArkoudaArrayGetitem, and all the setitem tests into TestArkoudaArraySetitem. But maybe not?

@drculhane drculhane 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.

Second observation:

Here are the names of the setitem and getitem tests. There are a lot more for get than for set. I would expect these lists to be nearly identical.

test_setitem_scalar
test_setitem_array
test_setitem_with_python_sequence_value
test_setitem_with_arkoudaarray_value
test_setitem_with_pdarray_value
test_setitem_empty_list_noop

test_getitem_scalar
test_getitem_slice
test_getitem_scalar_returns_python_scalar
test_getitem_slice_returns_arkouda_array
test_getitem_numpy_int_array_indexer
test_getitem_numpy_bool_array_indexer
test_getitem_python_list_of_ints
test_getitem_python_list_of_bools
test_getitem_empty_list_returns_empty_array
test_getitem_arkouda_int_indexer
test_getitem_rejects_unsupported_list_element_type
test_getitem_numpy_unsigned_int_indexer

@drculhane drculhane 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.

One more stray comment:

It's not from this PR, but the file tests/pandas/extension/arkouda_array_extension.py has a commented out line of code on line 156. It might be worth eliminating that while we're here.

@ajpotts
ajpotts force-pushed the 5105_ArkoudaExtensionArray_getitem branch from 1b171e0 to 4395a44 Compare January 26, 2026 16:50
@ajpotts
ajpotts force-pushed the 5105_ArkoudaExtensionArray_getitem branch from 6dd8e48 to a7a3bbc Compare January 26, 2026 17:32
@ajpotts

ajpotts commented Jan 27, 2026

Copy link
Copy Markdown
Contributor Author

@drculhane I made the changes you requested. Would you please take another look?

@ajpotts
ajpotts added this pull request to the merge queue Jan 28, 2026
Merged via the queue into Bears-R-Us:main with commit 34034c3 Jan 28, 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.

ArkoudaExtensionArray.__getitem__

3 participants