Skip to content

Inconsistent output in documentation example: num_classes not displayed in ClassLabel output #7129

@sergiopaniego

Description

@sergiopaniego

In the documentation for ClassLabel, there is an example of usage with the following code:

from datasets import Features
features = Features({'label': ClassLabel(num_classes=3, names=['bad', 'ok', 'good'])})
features

which expects to output (as stated in the documentation):

{'label': ClassLabel(num_classes=3, names=['bad', 'ok', 'good'], id=None)}

but it generates the following

{'label': ClassLabel(names=['bad', 'ok', 'good'], id=None)}

If my understanding is correct, this happens because although num_classes is used during the init of the object, it is afterward ignored:

num_classes: InitVar[Optional[int]] = None # Pseudo-field: ignored by asdict/fields when converting to/from dict

I would like to work on this issue if this is something needed 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions