Skip to content

FIX Metadata routing: register remainder when remainder="passthrough"#33665

Merged
jeremiedbb merged 11 commits intoscikit-learn:mainfrom
AnneBeyer:fix_metadata_remainder_passthrough
Apr 15, 2026
Merged

FIX Metadata routing: register remainder when remainder="passthrough"#33665
jeremiedbb merged 11 commits intoscikit-learn:mainfrom
AnneBeyer:fix_metadata_remainder_passthrough

Conversation

@AnneBeyer
Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Closes #33614

What does this implement/fix? Explain your changes.

When remainder="passthrough", it is now still registered in the MetadataRouter, even though it does not consume any meta data. (See the issue for details.)

I added a test for all types of remainder values I could think of, which goes a bit beyond the "passthrough" issue here, but it helped me understand some of the ideas behind metadata routing. I'm happy to simplify it, though, if it is too much here.

@StefanieSenger @jinlow

AI usage disclosure

I used AI assistance for:

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Any other comments?

@jeremiedbb jeremiedbb added this to the 1.9 milestone Apr 1, 2026
Copy link
Copy Markdown
Member

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @AnneBeyer

Comment thread sklearn/compose/tests/test_column_transformer.py Outdated
Comment thread sklearn/compose/tests/test_column_transformer.py Outdated
Comment thread doc/whats_new/upcoming_changes/sklearn.compose/33665.fix.rst Outdated
Copy link
Copy Markdown
Member

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

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

LGTM

@jeremiedbb jeremiedbb added Metadata Routing all issues related to metadata routing, slep006, sample props Waiting for Second Reviewer First reviewer is done, need a second one! labels Apr 5, 2026
@AnneBeyer AnneBeyer added this to Labs Apr 7, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Labs Apr 7, 2026
@AnneBeyer AnneBeyer moved this from Todo to In progress in Labs Apr 7, 2026
Copy link
Copy Markdown
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM.

Comment on lines +2928 to +2932
router = ct.get_metadata_routing()
if remainder == "drop":
assert "remainder" not in router._route_mappings
else:
assert "remainder" in router._route_mappings
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.

I don't think you need this, the regression test is that fit_transform shouldn't raise a KeyError. Using this private attribute here in the test makes it fragile.

@jeremiedbb jeremiedbb enabled auto-merge (squash) April 15, 2026 15:50
@jeremiedbb jeremiedbb merged commit 4cdcdc0 into scikit-learn:main Apr 15, 2026
36 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in Labs Apr 15, 2026
@AnneBeyer AnneBeyer deleted the fix_metadata_remainder_passthrough branch April 15, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Metadata Routing all issues related to metadata routing, slep006, sample props module:compose Waiting for Second Reviewer First reviewer is done, need a second one!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metadata Routing causes key error when remainder="passthrough"

3 participants