
def 		UpperCamelCase						(   lowercase_			,			lowercase_			,			lowercase_			,			lowercase_			,			lowercase_			,			lowercase_ )		->						Optional[Any]:


  '''simple docstring'''






  if index == r:
    for j in range(lowercase_ ):
      print(data[j]			,			end=""" """ )
    print(""" """ )
    return
  #  When no more elements are there to put in data[]
  if i >= n:
    return
  # current is included, put next at next location
  lowercase__	: int     		=   arr[i]
  combination_util(lowercase_			,			lowercase_			,			lowercase_			,			index + 1			,			lowercase_			,			i + 1 )
  # current is excluded, replace it with
  # next (Note that i+1 is passed, but
  # index is not changed)
  combination_util(lowercase_			,			lowercase_			,			lowercase_			,			lowercase_			,			lowercase_			,			i + 1 )
  # The main function that prints all combinations
  # of size r in arr[] of size n. This function
  # mainly uses combinationUtil()

def 		UpperCamelCase						(   lowercase_			,			lowercase_			,			lowercase_ )		->						Optional[Any]:


  '''simple docstring'''






  lowercase__	: int     		=   [0] * r
  # Print all combination using temporary array 'data[]'
  combination_util(lowercase_			,			lowercase_			,			lowercase_			,			0			,			lowercase_			,			0 )


if __name__ == "__main__":
     # Driver code to check the function above
     lowerCamelCase__     :		Any        = [1_0, 2_0, 3_0, 4_0, 5_0]
     print_combination(arr, len(arr), 3)
     # This code is contributed by Ambuj sahu













"""simple docstring"""


import io
import json

import fsspec
import pytest

from datasets import Dataset, DatasetDict, Features, NamedSplit, Value
from datasets.io.json import JsonDatasetReader, JsonDatasetWriter

from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases

def      UpperCamelCase							(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     ):
						assert isinstance(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     )
						assert dataset.num_rows == 4
						assert dataset.num_columns == 3
						assert dataset.column_names == ["col_1", "col_2", "col_3"]
						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							(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     ):
						UpperCamelCase				:		Tuple				   =			tmp_path / """cache"""
						UpperCamelCase				:		Optional[int]				   =			{"""col_1""": """string""", """col_2""": """int64""", """col_3""": """float64"""}
						with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
												UpperCamelCase				:		Tuple				   =			JsonDatasetReader(SCREAMING_SNAKE_CASE							,     cache_dir=SCREAMING_SNAKE_CASE							,     keep_in_memory=SCREAMING_SNAKE_CASE     ).read()
						_check_json_dataset(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     )

@pytest.mark.parametrize(
    """features"""							,     [
        None,
        {"""col_1""": """string""", """col_2""": """int64""", """col_3""": """float64"""},
        {"""col_1""": """string""", """col_2""": """string""", """col_3""": """string"""},
        {"""col_1""": """int32""", """col_2""": """int32""", """col_3""": """int32"""},
        {"""col_1""": """float32""", """col_2""": """float32""", """col_3""": """float32"""},
    ]							,     )
def      UpperCamelCase							(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     ):
						UpperCamelCase				:		Optional[Any]				   =			tmp_path / """cache"""
						UpperCamelCase				:		int				   =			{"""col_1""": """string""", """col_2""": """int64""", """col_3""": """float64"""}
						UpperCamelCase				:		Union[str, Any]				   =			features.copy() if features else default_expected_features
						UpperCamelCase				:		str				   =			(
						    Features({feature: Value(SCREAMING_SNAKE_CASE     ) for feature, dtype in features.items()}     ) if features is not None else None
						)
						UpperCamelCase				:		Optional[int]				   =			JsonDatasetReader(SCREAMING_SNAKE_CASE							,     features=SCREAMING_SNAKE_CASE							,     cache_dir=SCREAMING_SNAKE_CASE     ).read()
						_check_json_dataset(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     )

@pytest.mark.parametrize(
    """features"""							,     [
        None,
        {"""col_3""": """float64""", """col_1""": """string""", """col_2""": """int64"""},
    ]							,     )
def      UpperCamelCase							(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     ):
						UpperCamelCase				:		int				   =			tmp_path / """cache"""
						UpperCamelCase				:		Optional[int]				   =			{"""col_3""": """float64""", """col_1""": """string""", """col_2""": """int64"""}
						UpperCamelCase				:		Optional[Any]				   =			features.copy() if features else default_expected_features
						UpperCamelCase				:		Tuple				   =			(
						    Features({feature: Value(SCREAMING_SNAKE_CASE     ) for feature, dtype in features.items()}     ) if features is not None else None
						)
						UpperCamelCase				:		int				   =			JsonDatasetReader(SCREAMING_SNAKE_CASE							,     features=SCREAMING_SNAKE_CASE							,     cache_dir=SCREAMING_SNAKE_CASE     ).read()
						assert isinstance(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     )
						assert dataset.num_rows == 2
						assert dataset.num_columns == 3
						assert dataset.column_names == ["col_3", "col_1", "col_2"]
						for feature, expected_dtype in expected_features.items():
												assert dataset.features[feature].dtype == expected_dtype

def      UpperCamelCase							(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     ):
						# jsonl_312_path features are {"col_3": "float64", "col_1": "string", "col_2": "int64"}
						UpperCamelCase				:		str				   =			{"""col_2""": """int64""", """col_3""": """float64""", """col_1""": """string"""}
						UpperCamelCase				:		Tuple				   =			features.copy()
						UpperCamelCase				:		Tuple				   =			(
						    Features({feature: Value(SCREAMING_SNAKE_CASE     ) for feature, dtype in features.items()}     ) if features is not None else None
						)
						UpperCamelCase				:		Optional[int]				   =			tmp_path / """cache"""
						UpperCamelCase				:		List[Any]				   =			JsonDatasetReader(SCREAMING_SNAKE_CASE							,     features=SCREAMING_SNAKE_CASE							,     cache_dir=SCREAMING_SNAKE_CASE     ).read()
						assert isinstance(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     )
						assert dataset.num_rows == 2
						assert dataset.num_columns == 3
						assert dataset.column_names == ["col_2", "col_3", "col_1"]
						for feature, expected_dtype in expected_features.items():
												assert dataset.features[feature].dtype == expected_dtype

@pytest.mark.parametrize("""split"""							,     [None, NamedSplit("""train"""     ), """train""", """test"""]     )
def      UpperCamelCase							(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     ):
						UpperCamelCase				:		Optional[int]				   =			tmp_path / """cache"""
						UpperCamelCase				:		Any				   =			{"""col_1""": """string""", """col_2""": """int64""", """col_3""": """float64"""}
						UpperCamelCase				:		Dict				   =			JsonDatasetReader(SCREAMING_SNAKE_CASE							,     cache_dir=SCREAMING_SNAKE_CASE							,     split=SCREAMING_SNAKE_CASE     ).read()
						_check_json_dataset(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     )
						assert dataset.split == split if split else "train"

@pytest.mark.parametrize("""path_type"""							,     [str, list]     )
def      UpperCamelCase							(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     ):
						if issubclass(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     ):
												UpperCamelCase				:		List[str]				   =			jsonl_path
						elif issubclass(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     ):
												UpperCamelCase				:		List[str]				   =			[jsonl_path]
						UpperCamelCase				:		List[Any]				   =			tmp_path / """cache"""
						UpperCamelCase				:		List[Any]				   =			{"""col_1""": """string""", """col_2""": """int64""", """col_3""": """float64"""}
						UpperCamelCase				:		Optional[int]				   =			JsonDatasetReader(SCREAMING_SNAKE_CASE							,     cache_dir=SCREAMING_SNAKE_CASE     ).read()
						_check_json_dataset(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     )

def      UpperCamelCase							(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE=("train",)     ):
						assert isinstance(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     )
						for split in splits:
												UpperCamelCase				:		Optional[Any]				   =			dataset_dict[split]
												assert dataset.num_rows == 4
												assert dataset.num_columns == 3
												assert dataset.column_names == ["col_1", "col_2", "col_3"]
												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							(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     ):
						UpperCamelCase				:		int				   =			tmp_path / """cache"""
						UpperCamelCase				:		int				   =			{"""col_1""": """string""", """col_2""": """int64""", """col_3""": """float64"""}
						with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
												UpperCamelCase				:		Any				   =			JsonDatasetReader({"""train""": jsonl_path}							,     cache_dir=SCREAMING_SNAKE_CASE							,     keep_in_memory=SCREAMING_SNAKE_CASE     ).read()
						_check_json_datasetdict(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     )

@pytest.mark.parametrize(
    """features"""							,     [
        None,
        {"""col_1""": """string""", """col_2""": """int64""", """col_3""": """float64"""},
        {"""col_1""": """string""", """col_2""": """string""", """col_3""": """string"""},
        {"""col_1""": """int32""", """col_2""": """int32""", """col_3""": """int32"""},
        {"""col_1""": """float32""", """col_2""": """float32""", """col_3""": """float32"""},
    ]							,     )
def      UpperCamelCase							(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     ):
						UpperCamelCase				:		List[str]				   =			tmp_path / """cache"""
						UpperCamelCase				:		Optional[Any]				   =			{"""col_1""": """string""", """col_2""": """int64""", """col_3""": """float64"""}
						UpperCamelCase				:		Optional[Any]				   =			features.copy() if features else default_expected_features
						UpperCamelCase				:		Optional[Any]				   =			(
						    Features({feature: Value(SCREAMING_SNAKE_CASE     ) for feature, dtype in features.items()}     ) if features is not None else None
						)
						UpperCamelCase				:		Optional[Any]				   =			JsonDatasetReader({"""train""": jsonl_path}							,     features=SCREAMING_SNAKE_CASE							,     cache_dir=SCREAMING_SNAKE_CASE     ).read()
						_check_json_datasetdict(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     )

@pytest.mark.parametrize("""split"""							,     [None, NamedSplit("""train"""     ), """train""", """test"""]     )
def      UpperCamelCase							(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE     ):
						if split:
												UpperCamelCase				:		List[Any]				   =			{split: jsonl_path}
						else:
												UpperCamelCase				:		Tuple				   =			"""train"""
												UpperCamelCase				:		Union[str, Any]				   =			{"""train""": jsonl_path, """test""": jsonl_path}
						UpperCamelCase				:		Optional[Any]				   =			tmp_path / """cache"""
						UpperCamelCase				:		Optional[int]				   =			{"""col_1""": """string""", """col_2""": """int64""", """col_3""": """float64"""}
						UpperCamelCase				:		Union[str, Any]				   =			JsonDatasetReader(SCREAMING_SNAKE_CASE							,     cache_dir=SCREAMING_SNAKE_CASE     ).read()
						_check_json_datasetdict(SCREAMING_SNAKE_CASE							,     SCREAMING_SNAKE_CASE							,     splits=list(path.keys()     )     )
						assert all(dataset[split].split == split for split in path.keys()     )

def      UpperCamelCase							(SCREAMING_SNAKE_CASE     ):
						return json.load(SCREAMING_SNAKE_CASE     )

def      UpperCamelCase							(SCREAMING_SNAKE_CASE     ):
						return [json.loads(SCREAMING_SNAKE_CASE     ) for line in buffer]






class 							lowercase__			:

			"""simple docstring"""







			@pytest.mark.parametrize("""lines, load_json_function"""						,   [(True, load_json_lines), (False, load_json)]    )
			def   _a      (      self						,   _A						,   _A						,   _A    ):






									'''simple docstring'''







									with io.BytesIO() as buffer:
															JsonDatasetWriter(_A						,   _A						,   lines=_A    ).write()
															buffer.seek(0    )
															UpperCamelCase				:		Optional[Any]				   =			load_json_function(_A    )
									assert isinstance(_A						,   _A    )
									assert isinstance(exported_content[0]						,   _A    )
									assert len(_A    ) == 1_0







			@pytest.mark.parametrize(
			    """orient, container, keys, len_at"""						,   [
			        ("""records""", list, {"""tokens""", """labels""", """answers""", """id"""}, None),
			        ("""split""", dict, {"""columns""", """data"""}, """data"""),
			        ("""index""", dict, set("""0123456789"""    ), None),
			        ("""columns""", dict, {"""tokens""", """labels""", """answers""", """id"""}, """tokens"""),
			        ("""values""", list, None, None),
			        ("""table""", dict, {"""schema""", """data"""}, """data"""),
			    ]						,   )
			def   _a      (      self						,   _A						,   _A						,   _A						,   _A						,   _A    ):






									'''simple docstring'''







									with io.BytesIO() as buffer:
															JsonDatasetWriter(_A						,   _A						,   lines=_A						,   orient=_A    ).write()
															buffer.seek(0    )
															UpperCamelCase				:		str				   =			load_json(_A    )
									assert isinstance(_A						,   _A    )
									if keys:
															if container is dict:
																					assert exported_content.keys() == keys
															else:
																					assert exported_content[0].keys() == keys
									else:
															assert not hasattr(_A						,   """keys"""    ) and not hasattr(exported_content[0]						,   """keys"""    )
									if len_at:
															assert len(exported_content[len_at]    ) == 1_0
									else:
															assert len(_A    ) == 1_0







			@pytest.mark.parametrize("""lines, load_json_function"""						,   [(True, load_json_lines), (False, load_json)]    )
			def   _a      (      self						,   _A						,   _A						,   _A    ):






									'''simple docstring'''







									with io.BytesIO() as buffer:
															JsonDatasetWriter(_A						,   _A						,   lines=_A						,   num_proc=2    ).write()
															buffer.seek(0    )
															UpperCamelCase				:		List[Any]				   =			load_json_function(_A    )
									assert isinstance(_A						,   _A    )
									assert isinstance(exported_content[0]						,   _A    )
									assert len(_A    ) == 1_0







			@pytest.mark.parametrize(
			    """orient, container, keys, len_at"""						,   [
			        ("""records""", list, {"""tokens""", """labels""", """answers""", """id"""}, None),
			        ("""split""", dict, {"""columns""", """data"""}, """data"""),
			        ("""index""", dict, set("""0123456789"""    ), None),
			        ("""columns""", dict, {"""tokens""", """labels""", """answers""", """id"""}, """tokens"""),
			        ("""values""", list, None, None),
			        ("""table""", dict, {"""schema""", """data"""}, """data"""),
			    ]						,   )
			def   _a      (      self						,   _A						,   _A						,   _A						,   _A						,   _A    ):






									'''simple docstring'''







									with io.BytesIO() as buffer:
															JsonDatasetWriter(_A						,   _A						,   lines=_A						,   orient=_A						,   num_proc=2    ).write()
															buffer.seek(0    )
															UpperCamelCase				:		Dict				   =			load_json(_A    )
									assert isinstance(_A						,   _A    )
									if keys:
															if container is dict:
																					assert exported_content.keys() == keys
															else:
																					assert exported_content[0].keys() == keys
									else:
															assert not hasattr(_A						,   """keys"""    ) and not hasattr(exported_content[0]						,   """keys"""    )
									if len_at:
															assert len(exported_content[len_at]    ) == 1_0
									else:
															assert len(_A    ) == 1_0







			def   _a      (      self						,   _A    ):






									'''simple docstring'''







									with pytest.raises(_A    ):
															with io.BytesIO() as buffer:
																					JsonDatasetWriter(_A						,   _A						,   num_proc=0    )







			@pytest.mark.parametrize("""compression, extension"""						,   [("""gzip""", """gz"""), ("""bz2""", """bz2"""), ("""xz""", """xz""")]    )
			def   _a      (      self						,   _A						,   _A						,   _A						,   _A						,   _A    ):






									'''simple docstring'''







									UpperCamelCase				:		List[str]				   =			tmp_path_factory.mktemp("""data"""    ) / f"""test.json.{extension}"""
									UpperCamelCase				:		Tuple				   =			str(shared_datadir / f"""test_file.json.{extension}"""    )
									JsonDatasetWriter(_A						,   _A						,   compression=_A    ).write()

									with fsspec.open(_A						,   """rb"""						,   compression="""infer"""    ) as f:
															UpperCamelCase				:		Dict				   =			f.read()
									with fsspec.open(_A						,   """rb"""						,   compression="""infer"""    ) as f:
															UpperCamelCase				:		Tuple				   =			f.read()
									assert exported_content == original_content



