Skip to content

Feature: Custom encoders returning multiple components#3069

Merged
dennisbader merged 12 commits into
unit8co:masterfrom
mwaldleben:feature/custom-encoders-multi-components
May 29, 2026
Merged

Feature: Custom encoders returning multiple components#3069
dennisbader merged 12 commits into
unit8co:masterfrom
mwaldleben:feature/custom-encoders-multi-components

Conversation

@mwaldleben
Copy link
Copy Markdown
Contributor

@mwaldleben mwaldleben commented Apr 14, 2026

Checklist before merging this PR:

  • Mentioned all issues that this PR fixes or addresses.
  • Summarized the updates of this PR under Summary.
  • Added an entry under Unreleased in the Changelog.

Fixes #2806.

Summary

This PR adds support in CallableIndexEncoder for custom encoders to return multiple components. A single callable used via add_encoders["custom"] can now return either a 1D array of shape (len(index),) or a 2D array of shape (len(index), n).

For a 2D output, one encoded covariate component per column are created. The number of components is detected at initialization time. If the callable does not accept a supported index type or does not return the correct output shape, a ValueError is raised at initialization.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.48%. Comparing base (91d266b) to head (46a48aa).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3069      +/-   ##
==========================================
+ Coverage   96.47%   96.48%   +0.01%     
==========================================
  Files         160      160              
  Lines       17262    17285      +23     
==========================================
+ Hits        16654    16678      +24     
+ Misses        608      607       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mwaldleben mwaldleben force-pushed the feature/custom-encoders-multi-components branch from cd20aec to 1ab9431 Compare May 25, 2026 21:39
@mwaldleben mwaldleben changed the title Feature/custom encoders multi components Feature: Custom encoders with multiple components May 26, 2026
@mwaldleben mwaldleben changed the title Feature: Custom encoders with multiple components Feature: Custom encoders returning multiple components May 26, 2026
@mwaldleben mwaldleben marked this pull request as ready for review May 27, 2026 07:23
@mwaldleben mwaldleben requested a review from dennisbader as a code owner May 27, 2026 07:23
Copy link
Copy Markdown
Collaborator

@dennisbader dennisbader left a comment

Choose a reason for hiding this comment

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

Beautiful PR, thanks a lot @mwaldleben 🚀

I just pushed some minor changes that are unrelated to your PR (we're removing the raise_if* helpers slowly so I took the chance to do it for the encoders module in this PR).

I'll merge once all tests have passed 💯

@dennisbader dennisbader merged commit a26bf1e into unit8co:master May 29, 2026
9 checks passed
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.

[QUESTION] ValueError with add_encoders Custom Function Returning Multiple Components

2 participants