Repository navigation
only evaluate items of builtin collections not subclasses - #1612
Merged
rcap107 merged 2 commits intoSep 16, 2025
Merged
Conversation
rcap107
approved these changes
Sep 16, 2025
rcap107
left a comment
Member
There was a problem hiding this comment.
LGTM, thanks @jeromedockes
I wonder how many people were affected by this, besides you 😝
I noted down this should end up in the documentation somehow, maybe as a possible error
rcap107
pushed a commit
to rcap107/skrub
that referenced
this pull request
Sep 25, 2025
rcap107
pushed a commit
that referenced
this pull request
Sep 25, 2025
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.
When evaluating a DataOp, we evaluate built-in collections such as lists by evaluating each item and then reconstructing the list. This allows things like
choose_from([choose_from(...), choose_from(...)])(because we recurse into the list) and many more useful cases. This is similar to what scikit-learnclonedoes.However, we should not do it for instances of subclasses of those builtin-types, because their initializers may work differently or they may have other invariants we do not know about so we may not be able to reconstruct the new collection from the evaluated items.
sklearn.cloneonly considers the built-in classes, not their subclasses.At the moment we also open subclasses, this PR fixes that (ie makes the behavior the same as
clone)eg this fails on main but works in this PR
(In main we get
TypeError: Pair.__new__() missing 1 required positional argument: 'second'when trying to callPair([1, 2]))