




'''simple docstring'''





import pytest

from datasets import Dataset, DatasetDict, Features, NamedSplit, Value
from datasets.io.text import TextDatasetReader

from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases


def 					UpperCamelCase_(     snake_case							:	List[str]							,    snake_case							:	Tuple					):

							'''simple docstring'''






							assert isinstance(__SCREAMING_SNAKE_CASE							,    __SCREAMING_SNAKE_CASE					)
							assert dataset.num_rows == 4
							assert dataset.num_columns == 1
							assert dataset.column_names == ["text"]
							for feature, expected_dtype in expected_features.items():
														assert dataset.features[feature].dtype == expected_dtype


@pytest.mark.parametrize("keep_in_memory"							,    [False, True]					)
def 					UpperCamelCase_(     snake_case							:	str							,    snake_case							:	Optional[int]							,    snake_case							:	Union[str, Any]					):

							'''simple docstring'''






							snake_case_      =				tmp_path / "cache"
							snake_case_      =				{"text": "string"}
							with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
														snake_case_      =				TextDatasetReader(__SCREAMING_SNAKE_CASE							,    cache_dir=__SCREAMING_SNAKE_CASE							,    keep_in_memory=__SCREAMING_SNAKE_CASE					).read()
							_check_text_dataset(__SCREAMING_SNAKE_CASE							,    __SCREAMING_SNAKE_CASE					)


@pytest.mark.parametrize(
    "features"							,    [
        None,
        {"text": "string"},
        {"text": "int32"},
        {"text": "float32"},
    ]							,    )
def 					UpperCamelCase_(     snake_case							:	Dict							,    snake_case							:	List[str]							,    snake_case							:	int					):

							'''simple docstring'''






							snake_case_      =				tmp_path / "cache"
							snake_case_      =				{"text": "string"}
							snake_case_      =				features.copy() if features else default_expected_features
							snake_case_      =				(
							    Features({feature: Value(__SCREAMING_SNAKE_CASE					) for feature, dtype in features.items()}					) if features is not None else None
							)
							snake_case_      =				TextDatasetReader(__SCREAMING_SNAKE_CASE							,    features=__SCREAMING_SNAKE_CASE							,    cache_dir=__SCREAMING_SNAKE_CASE					).read()
							_check_text_dataset(__SCREAMING_SNAKE_CASE							,    __SCREAMING_SNAKE_CASE					)


@pytest.mark.parametrize("split"							,    [None, NamedSplit("train"					), "train", "test"]					)
def 					UpperCamelCase_(     snake_case							:	Tuple							,    snake_case							:	int							,    snake_case							:	Union[str, Any]					):

							'''simple docstring'''






							snake_case_      =				tmp_path / "cache"
							snake_case_      =				{"text": "string"}
							snake_case_      =				TextDatasetReader(__SCREAMING_SNAKE_CASE							,    cache_dir=__SCREAMING_SNAKE_CASE							,    split=__SCREAMING_SNAKE_CASE					).read()
							_check_text_dataset(__SCREAMING_SNAKE_CASE							,    __SCREAMING_SNAKE_CASE					)
							assert dataset.split == split if split else "train"


@pytest.mark.parametrize("path_type"							,    [str, list]					)
def 					UpperCamelCase_(     snake_case							:	str							,    snake_case							:	Optional[Any]							,    snake_case							:	Tuple					):

							'''simple docstring'''






							if issubclass(__SCREAMING_SNAKE_CASE							,    __SCREAMING_SNAKE_CASE					):
														snake_case_      =				text_path
							elif issubclass(__SCREAMING_SNAKE_CASE							,    __SCREAMING_SNAKE_CASE					):
														snake_case_      =				[text_path]
							snake_case_      =				tmp_path / "cache"
							snake_case_      =				{"text": "string"}
							snake_case_      =				TextDatasetReader(__SCREAMING_SNAKE_CASE							,    cache_dir=__SCREAMING_SNAKE_CASE					).read()
							_check_text_dataset(__SCREAMING_SNAKE_CASE							,    __SCREAMING_SNAKE_CASE					)


def 					UpperCamelCase_(     snake_case							:	Optional[Any]							,    snake_case							:	Tuple							,    snake_case							:	List[str]=("train",)					):

							'''simple docstring'''






							assert isinstance(__SCREAMING_SNAKE_CASE							,    __SCREAMING_SNAKE_CASE					)
							for split in splits:
														snake_case_      =				dataset_dict[split]
														assert dataset.num_rows == 4
														assert dataset.num_columns == 1
														assert dataset.column_names == ["text"]
														for feature, expected_dtype in expected_features.items():
																					assert dataset.features[feature].dtype == expected_dtype


@pytest.mark.parametrize("keep_in_memory"							,    [False, True]					)
def 					UpperCamelCase_(     snake_case							:	List[str]							,    snake_case							:	List[Any]							,    snake_case							:	Any					):

							'''simple docstring'''






							snake_case_      =				tmp_path / "cache"
							snake_case_      =				{"text": "string"}
							with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
														snake_case_      =				TextDatasetReader({"train": text_path}							,    cache_dir=__SCREAMING_SNAKE_CASE							,    keep_in_memory=__SCREAMING_SNAKE_CASE					).read()
							_check_text_datasetdict(__SCREAMING_SNAKE_CASE							,    __SCREAMING_SNAKE_CASE					)


@pytest.mark.parametrize(
    "features"							,    [
        None,
        {"text": "string"},
        {"text": "int32"},
        {"text": "float32"},
    ]							,    )
def 					UpperCamelCase_(     snake_case							:	str							,    snake_case							:	Optional[Any]							,    snake_case							:	Tuple					):

							'''simple docstring'''






							snake_case_      =				tmp_path / "cache"
							# CSV file loses col_1 string dtype information: default now is "int64" instead of "string"
							snake_case_      =				{"text": "string"}
							snake_case_      =				features.copy() if features else default_expected_features
							snake_case_      =				(
							    Features({feature: Value(__SCREAMING_SNAKE_CASE					) for feature, dtype in features.items()}					) if features is not None else None
							)
							snake_case_      =				TextDatasetReader({"train": text_path}							,    features=__SCREAMING_SNAKE_CASE							,    cache_dir=__SCREAMING_SNAKE_CASE					).read()
							_check_text_datasetdict(__SCREAMING_SNAKE_CASE							,    __SCREAMING_SNAKE_CASE					)




@pytest.mark.parametrize("split"							,    [None, NamedSplit("train"					), "train", "test"]					)
def 					UpperCamelCase_(     snake_case							:	Tuple							,    snake_case							:	Optional[Any]							,    snake_case							:	Any					):

							'''simple docstring'''






							if split:
														snake_case_      =				{split: text_path}
							else:
														snake_case_      =				"train"
														snake_case_      =				{"train": text_path, "test": text_path}
							snake_case_      =				tmp_path / "cache"
							snake_case_      =				{"text": "string"}
							snake_case_      =				TextDatasetReader(__SCREAMING_SNAKE_CASE							,    cache_dir=__SCREAMING_SNAKE_CASE					).read()
							_check_text_datasetdict(__SCREAMING_SNAKE_CASE							,    __SCREAMING_SNAKE_CASE							,    splits=list(path.keys()					)					)
							assert all(dataset[split].split == split for split in path.keys()					)












'''simple docstring'''





def 					UpperCamelCase_(     snake_case							:	int							,    snake_case							:	int					):

							'''simple docstring'''






							while b:
														snake_case_ ,				snake_case_      =				b, a % b
							return a


def 					UpperCamelCase_(     snake_case							:	int							,    snake_case							:	int					):

							'''simple docstring'''






							return a if b == 0 else euclidean_gcd_recursive(snake_case							,    a % b					)


def 					UpperCamelCase_(     ):

							'''simple docstring'''






							print(f'euclidean_gcd(3, 5) = {euclidean_gcd(3							,    5					)}'					)
							print(f'euclidean_gcd(5, 3) = {euclidean_gcd(5							,    3					)}'					)
							print(f'euclidean_gcd(1, 3) = {euclidean_gcd(1							,    3					)}'					)
							print(f'euclidean_gcd(3, 6) = {euclidean_gcd(3							,    6					)}'					)
							print(f'euclidean_gcd(6, 3) = {euclidean_gcd(6							,    3					)}'					)

							print(f'euclidean_gcd_recursive(3, 5) = {euclidean_gcd_recursive(3							,    5					)}'					)
							print(f'euclidean_gcd_recursive(5, 3) = {euclidean_gcd_recursive(5							,    3					)}'					)
							print(f'euclidean_gcd_recursive(1, 3) = {euclidean_gcd_recursive(1							,    3					)}'					)
							print(f'euclidean_gcd_recursive(3, 6) = {euclidean_gcd_recursive(3							,    6					)}'					)
							print(f'euclidean_gcd_recursive(6, 3) = {euclidean_gcd_recursive(6							,    3					)}'					)


if __name__ == "__main__":
		main()




