Repository navigation
Narwhalify DiscreteParameter.transform - #862
Merged
Merged
Conversation
- Drop the spurious ParameterEncoding | None placeholder field from DiscreteParameter; encoding is only meaningful on concrete label-like subclasses that actually use it - Remove the vestigial CustomEncoding field from CustomDiscreteParameter; the encoding is the user-supplied data DataFrame itself, so the field carried no information and was never read - Simplify DiscreteParameter.transform() to the identity path (series.to_frame()); move the comp_df merge logic into a new transform() override on _DiscreteLabelLikeParameter
Avoid materialization of comp_df
DiscreteParameter.transformDiscreteParameter.transform
AdrianSosic
force-pushed
the
refactor/encoded_parameters
branch
from
July 17, 2026 09:16
916f2c2 to
40e2d0f
Compare
AdrianSosic
force-pushed
the
refactor/encoded_parameters
branch
from
July 17, 2026 09:25
40e2d0f to
0cdd025
Compare
Zero coefficients are now rejected (incoming change from main)
myrazma
reviewed
Jul 20, 2026
Co-authored-by: Myra <myra.zmarsly@outlook.com>
AdrianSosic
force-pushed
the
refactor/encoded_parameters
branch
from
July 20, 2026 10:43
5ebac99 to
07f9025
Compare
fabianliebig
approved these changes
Jul 20, 2026
fabianliebig
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. I also think it make sense to first create a first version and then adjust and see how narwahl can be implemented best :)
fabianliebig
requested changes
Jul 21, 2026
fabianliebig
approved these changes
Jul 21, 2026
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.
Cleans up the discrete parameter hierarchy and broadens the
transforminterface toward narwhals-native evaluation, laying the groundwork for backend-agnostic computational representations.Background
The long-term goal is to make
DiscreteParameter.transformfully backend-agnostic: accept any narwhals-compatible input and return a corresponding native eager dataframe. This PR implements the interface change and migratesNumericalDiscreteParameterandCategoricalParameterfully;SubstanceParameterandCustomDiscreteParameterretain a pandas-backed_comp_dffallback pending a follow-up.Several related cleanups are bundled here because they are prerequisites or natural companions: the encoding attribute was spuriously placed on the base class,
CustomEncodingwas aCategoricalEncodingenum value that never applied toCustomDiscreteParameter(whose "encoding" is the user-supplied DataFrame itself, not an enum choice), several parameter fields lacked validators/converters, andvalidate_parameter_inputhad aniterrows-based loop that caused significant slowdowns onceTableCandidatesbegan calling it at construction time.