From 347f1664a31c1c0fcb6a1a0914ebfb99c134e116 Mon Sep 17 00:00:00 2001 From: Albert Villanova del Moral <8515462+albertvillanova@users.noreply.github.com> Date: Fri, 26 Jul 2024 09:51:52 +0200 Subject: [PATCH] Fix doc generation when NamedSplit is used as parameter default value (#7036) * Force CI re-run * Test NamedSplit inequality * Fix NamedSplit equality --- src/datasets/splits.py | 2 +- tests/test_splits.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/datasets/splits.py b/src/datasets/splits.py index fd4966cb400..5cca4e8b966 100644 --- a/src/datasets/splits.py +++ b/src/datasets/splits.py @@ -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 diff --git a/tests/test_splits.py b/tests/test_splits.py index bce980e36ab..364880ec686 100644 --- a/tests/test_splits.py +++ b/tests/test_splits.py @@ -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 @@ -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