Skip to content

BUG: preserve assertion errors for nested sequence length mismatches - #69015

Merged
jbrockmendel merged 2 commits into
pandas-dev:mainfrom
Ai-Eastern:fix/69014-nested-length-astra-ultra
Sep 21, 2026
Merged

jbrockmendel merged 2 commits into
pandas-dev:mainfrom
Ai-Eastern:fix/69014-nested-length-astra-ultra

Conversation

@Ai-Eastern

Copy link
Copy Markdown
Contributor

When object-dtype Series or DataFrame values contain nested sequences of different lengths, constructing the optional set difference can raise TypeError before the comparison reports its AssertionError. Skip that optional diagnostic when the elements cannot be hashed, while preserving it for hashable values. Add regression coverage for both comparison directions, the Series/DataFrame error details, and the hashable diagnostic.

AI disclosure: Developed with OpenAI Codex using GPT-6 Astra (gpt-6-astra), reasoning effort ultra. The same model and effort were used for reproduction, root-cause analysis, implementation, regression tests, the release note, local validation, and this PR draft. Two same-model read-only assistants checked issue/policy status and reviewed edge cases/the final diff. The agents were instructed to follow AGENTS.md. No work from the previous attempted branch or workspace was read, reused, or cherry-picked.

Check exactly one of the following, per the automated contributions policy:

  • I did not use AI to develop this pull request.
  • I used AI to develop this pull request. I prompted it to follow AGENTS.md, I have reviewed and understood every change, and I have described above how I used it and exactly which tool, model version, and effort setting.

Local validation on Windows x64, CPython 3.12.13 and NumPy 2.5.3, using the compiled Cython extension from this checkout:

# Before the fix, focused tests:
12 failed (unhashable TypeError), 2 passed, 313 deselected

# After the fix, the same focused tests:
14 passed, 313 deselected

python -m pytest pandas/tests/util -q -ra --tb=short
1084 passed, 18 skipped, 2 xfailed

python -m pre_commit run --files pandas/_libs/testing.pyx pandas/tests/util/test_assert_almost_equal.py pandas/tests/util/test_assert_frame_equal.py doc/source/whatsnew/v3.1.0.rst
All applicable hooks passed (exit 0).

git diff --check
exit 0

Of the 18 skips, 17 require the optional pyarrow dependency and one is the existing missing-file fixture case. The two expected failures concern the existing check_exact_index default. The full pandas suite, documentation build, and upstream CI have not been run locally.

@github-actions github-actions Bot added the Awaiting Review PR in the maintainers' court; exempt from staleness label Sep 19, 2026
Comment thread pandas/_libs/testing.pyx Outdated
try:
r = list(set(a) ^ set(b))
except TypeError:
# Nested sequences can contain unhashable elements.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you include # GH#69014 here

@github-actions github-actions Bot removed the Awaiting Review PR in the maintainers' court; exempt from staleness label Sep 20, 2026
@jbrockmendel
jbrockmendel merged commit 6a2edf9 into pandas-dev:main Sep 21, 2026
52 checks passed
@jbrockmendel

Copy link
Copy Markdown
Member

thanks @Ai-Eastern

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.

BUG: test assert methods failing on object dtype column with lists of different nesting

2 participants