Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Feature base class to improve support for user-defined features #7221

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

alex-hh
Copy link
Contributor

@alex-hh alex-hh commented Oct 11, 2024

intended as fix for #7220 if this kind of extensibility is something that datasets is willing to support!

class ListOfStrs:
    requires_encoding = True
    def encode_example(self, value):
        if isinstance(value, str):
            return [str]
        else:
            return value
feats = Features(strlist=ListOfStrs())
feats.encode_example({"strlist": "a"})["strlist"] == feats["strlist"].encode_example("a")

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.

1 participant