BUG: make duplicated hashtable test levels distinct - #66786
Draft
aryansk wants to merge 2 commits into
Draft
Conversation
test_duplicated_hashtable_impl instantiated a fresh default_rng(2) inside the comprehension, so every level drew the identical sequence and the MultiIndex collapsed to only n distinct label tuples. Reuse one generator across levels so the test exercises duplicate detection over a much wider input, as it did before pandas-dev#54209. Closes pandas-dev#66774
Contributor
|
Thanks for the pull request, @aryansk! It's linked to #66774, but that issue isn't assigned to you yet. To make sure two people don't unknowingly work on the same thing, we ask contributors to claim an issue first. Just comment |
| - Bug in :meth:`DataFrame.select_dtypes` with an :class:`~pandas.api.extensions.ExtensionDtype` subclass such as :class:`ArrowDtype` or :class:`DatetimeTZDtype` raising ``TypeError``, emitting a spurious ``UserWarning``, or selecting the wrong columns; passing such a class now selects every column whose dtype is an instance of that class (:issue:`65366`) | ||
| - Bug in :meth:`Series.transform` and :meth:`DataFrame.transform` where passing a list of duplicate function names did not raise :class:`errors.SpecificationError` (:issue:`54929`) | ||
| - Bug in ``register_option`` where registering an option whose name was a prefix of an existing option (e.g. ``"a.b"`` when ``"a.b.c"`` was already registered) silently overwrote the existing option's namespace instead of raising (:issue:`29242`) | ||
| - Fixed ``MultiIndex`` duplicate detection tests instantiating a fresh RNG for every level, so each level received identical code arrays and the index collapsed to only ``n`` distinct label tuples (:issue:`66774`) |
Member
There was a problem hiding this comment.
Tests don’t get whatsnew entries
Open
3 tasks
Member
|
You checked the box saying you had said which AI you used, but you didn't actually do that. |
Author
|
Thanks @jbrockmendel — two fixes:
Issue #66774 is now claimed via |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes BUG: test_duplicated_hashtable_impl generates identical codes for every MultiIndex level #66774
Tests added and passed if fixing a bug or adding a new feature
All code checks passed.
Added an entry in the latest
doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.I have reviewed and followed all the contribution guidelines
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 — e.g.claude opus 4.8 (xhigh), not justclaude.What this changes
test_duplicated_hashtable_implinstantiatednp.random.default_rng(2)inside the comprehension, so a new generator with the same seed was created on every iteration and each level received the identical code sequence. TheMultiIndexthen collapsed to onlyndistinct label tuples, so the test exercised duplicate detection over a far narrower input than intended (it regressed in #54209, which used to draw once per level from a shared RNG).This reuses a single generator across levels, restoring distinct codes per level (53 distinct tuples vs 6 for the same seed) while keeping the parametrized
keepassertions intact.How I used AI
I used an AI coding agent (opencode, Anthropic Claude model family) to help analyze the issue, verify the RNG behavior against a source build, and draft this change. I reviewed and understood the final diff (a one-line RNG refactor) and validated it by running the full
test_duplicates.pymodule against a local source build — all 51 tests pass.Closes: #66774