Tie feature labels to variable names so they can't silently drift (uses 3.12 and 3.14)#644
Draft
audreyfeldroy wants to merge 1 commit intomainfrom
Draft
Tie feature labels to variable names so they can't silently drift (uses 3.12 and 3.14)#644audreyfeldroy wants to merge 1 commit intomainfrom
audreyfeldroy wants to merge 1 commit intomainfrom
Conversation
Feature labels are now variable names. The 23-element feature vector is destructured into named variables, and a Python 3.14 template string passes them to _render_features(). The function walks the template interpolations and emits name=value pairs using each interpolation's .expression attribute. There is no separate name list to maintain, so labels can't go stale when features are added or reordered. Key design decisions: - type FeatureVector = list[float] (Python 3.12) gives the feature vector a first-class name in the type system - Native str | bytes | Path union syntax for public API signatures - tree.py imports FeatureVector under TYPE_CHECKING to avoid circular imports at runtime - The 23-line feature index docstring in _compute_features is removed; the destructuring assignment is the index Requires Python 3.14+ for t-strings. The support-python-310 branch serves users who need the older floor.
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.
Feature labels are now variable names. The 23-element feature vector is destructured into named variables, and a Python 3.14 template string passes them to _render_features(). The function walks the template interpolations and emits name=value pairs using each interpolation's .expression attribute. There is no separate name list to maintain, so labels can't go stale when features are added or reordered.
Key design decisions:
Requires Python 3.14+ for t-strings. Putting this on hold for now; currently considering the support-python-310 branch to serve cookieplone users who need the older floor.