-
-
Notifications
You must be signed in to change notification settings - Fork 211
Closed
Labels
Good First IssueIssues suitable for people new to contributing to openml-python!Issues suitable for people new to contributing to openml-python!bug
Description
When creating a task locally the __repr__ function raises a TypeError due to the class_labels attribute being None. This persists even after publishing it, which makes exposure of this bug more prevalent (because the task.publish() returns itself which invokes __repr__ if ran in an interactive shell without assigning the result to a variable):
import openml
openml.config.start_configuration_for_example()
t = openml.tasks.create_task(openml.tasks.task.TaskType.SUPERVISED_CLASSIFICATION, 128, 2, "class", "weighted_recall")
t.publish()
>>> Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\repositories\openml-python\openml\base.py", line 19, in __repr__
body_fields = self._get_repr_body_fields()
File "D:\repositories\openml-python\openml\tasks\task.py", line 101, in _get_repr_body_fields
fields["# of Classes"] = len(getattr(self, "class_labels"))
TypeError: object of type 'NoneType' has no len()Suggested expected behavior: leave it out of the __repr__ if class_labels is None, i.e. extend the check of task#100 to skip assignment if class_labels is None. I don't think it's worth the added complexity to support an accurate class_labels in this niche scenario.
LaurensKrudde
Metadata
Metadata
Assignees
Labels
Good First IssueIssues suitable for people new to contributing to openml-python!Issues suitable for people new to contributing to openml-python!bug