Skip to content

Commit

Permalink
Fix doc generation when NamedSplit is used as parameter default value (
Browse files Browse the repository at this point in the history
…#7036)

* Force CI re-run

* Test NamedSplit inequality

* Fix NamedSplit equality
  • Loading branch information
albertvillanova authored Jul 26, 2024
1 parent 9c98e06 commit 347f166
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/datasets/splits.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def __eq__(self, other):
elif isinstance(other, str): # Other should be string
return self._name == other
else:
raise ValueError(f"Equality not supported between split {self} and {other}")
return False

def __lt__(self, other):
return self._name < other._name # pylint: disable=protected-access
Expand Down
9 changes: 8 additions & 1 deletion tests/test_splits.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import inspect

import pytest

from datasets.splits import SplitDict, SplitInfo
from datasets.splits import Split, SplitDict, SplitInfo
from datasets.utils.py_utils import asdict


Expand Down Expand Up @@ -34,3 +36,8 @@ def test_split_dict_asdict_has_dataset_name(split_info):
split_dict_asdict = asdict(SplitDict({"train": split_info}))
assert "dataset_name" in split_dict_asdict["train"]
assert split_dict_asdict["train"]["dataset_name"] == split_info.dataset_name


def test_named_split_inequality():
# Used while building the docs, when set as a default parameter value in a function signature
assert Split.TRAIN != inspect.Parameter.empty

0 comments on commit 347f166

Please sign in to comment.