Skip to content

Conversation

@MaxGhenis
Copy link
Contributor

Summary

  • Fixed ParameterNodeAtInstant.__getitem__() to convert pandas StringArray to numpy array before using for fancy indexing

Problem

In pandas 3.0, string columns use StringDtype by default, producing StringArray objects. When a StringArray is passed to ParameterNodeAtInstant.__getitem__(), it fails with:

TypeError: unhashable type: 'StringArray'

This is because StringArray is not hashable and can't be used as a dict key in self._children[key].

Solution

Added the same check that already exists in VectorialParameterNodeAtInstant.__getitem__():

if hasattr(key, "__array__") and not isinstance(key, numpy.ndarray):
    key = numpy.asarray(key)

This converts pandas arrays (like StringArray) to numpy arrays before checking for fancy indexing.

Test plan

  • Added regression test test_parameter_node_at_instant_getitem_with_string_array
  • Verified test fails before fix
  • Verified test passes after fix
  • All pandas3 compatibility tests pass

Fixes #429

🤖 Generated with Claude Code

MaxGhenis and others added 4 commits January 25, 2026 08:49
ParameterNodeAtInstant.__getitem__() now converts pandas StringArray
to numpy array before checking for fancy indexing. Without this fix,
passing a StringArray as a key raises:
TypeError: unhashable type: 'StringArray'

This mirrors the existing fix in VectorialParameterNodeAtInstant.

Fixes #429

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@MaxGhenis MaxGhenis merged commit 5746049 into master Jan 25, 2026
14 checks passed
@MaxGhenis MaxGhenis deleted the fix-stringarray-hashable branch January 25, 2026 14:03
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.

Pandas 3.0: TypeError: unhashable type 'StringArray' in parameter_node_at_instant.py

2 participants