Fix add_column parameter order so feature precedes new_fingerprint#8306
Open
gaurav0107 wants to merge 1 commit into
Open
Fix add_column parameter order so feature precedes new_fingerprint#8306gaurav0107 wants to merge 1 commit into
add_column parameter order so feature precedes new_fingerprint#8306gaurav0107 wants to merge 1 commit into
Conversation
Dataset.add_column documents `feature` as its third argument and every sibling @fingerprint_transform method (cast_column, rename_column, remove_columns, select_columns, ...) keeps `new_fingerprint` as the last parameter. add_column had them reversed, so a docstring-conformant positional call `ds.add_column(name, column, feature)` raised "TypeError: got multiple values for argument 'new_fingerprint'" because the fingerprint_transform decorator injects new_fingerprint by keyword. Reorder the signature to (name, column, feature=None, new_fingerprint=None). The decorator references new_fingerprint by keyword, so this is safe for existing keyword callers, and no add_column caller passes feature or new_fingerprint positionally. Fixes huggingface#7864
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.
What
Dataset.add_column's signature is(name, column, new_fingerprint=None, feature=None), but:feature(notnew_fingerprint), and@fingerprint_transformmethod keepsnew_fingerprintas the last parameter (e.g.cast_column(column, feature, new_fingerprint=None),rename_column,remove_columns,select_columns).Because
new_fingerprintsits beforefeature, a docstring-conformant positional call raises:The
fingerprint_transformdecorator injectsnew_fingerprintas a keyword argument, so the positional value collides with it.Fix
Reorder the signature to
(name, column, feature=None, new_fingerprint=None), matching the docstring and thecast_columnconvention. The decorator referencesnew_fingerprintby keyword, so this is safe for existing keyword callers, and noDataset.add_columncaller in the repo passesfeature/new_fingerprintpositionally.Test
Added
test_add_column_feature_argumentintests/test_arrow_dataset.py, asserting that a positionalfeatureis honored, the keyword form still works, and thenew_fingerprintkeyword is still respected. The test fails onmain(TypeError) and passes with this change.Fixes #7864
🤖 Opened with Superhuman, an open-source contribution agent.