

"""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 	lowerCAmelCase    (       __UpperCamelCase				,     __UpperCamelCase   ):
 '''simple docstring'''





 assert isinstance(__UpperCamelCase				,     __UpperCamelCase   )
 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 	lowerCAmelCase    (       __UpperCamelCase				,     __UpperCamelCase				,     __UpperCamelCase   ):
 '''simple docstring'''





 UpperCAmelCase__       :	List[Any]        =       tmp_path / """cache"""
 UpperCAmelCase__       :	List[Any]        =       {"""text""": """string"""}
 with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
  UpperCAmelCase__       :	Union[str, Any]        =       TextDatasetReader(__UpperCamelCase				,     cache_dir=__UpperCamelCase				,     keep_in_memory=__UpperCamelCase   ).read()
 _check_text_dataset(__UpperCamelCase				,     __UpperCamelCase   )
@pytest.mark.parametrize(
    """features"""				,     [
        None,
        {"""text""": """string"""},
        {"""text""": """int32"""},
        {"""text""": """float32"""},
    ]				,     )
def 	lowerCAmelCase    (       __UpperCamelCase				,     __UpperCamelCase				,     __UpperCamelCase   ):
 '''simple docstring'''





 UpperCAmelCase__       :	Dict        =       tmp_path / """cache"""
 UpperCAmelCase__       :	Tuple        =       {"""text""": """string"""}
 UpperCAmelCase__       :	Dict        =       features.copy() if features else default_expected_features
 UpperCAmelCase__       :	Tuple        =       (
     Features({feature: Value(__UpperCamelCase   ) for feature, dtype in features.items()}   ) if features is not None else None
 )
 UpperCAmelCase__       :	Optional[Any]        =       TextDatasetReader(__UpperCamelCase				,     features=__UpperCamelCase				,     cache_dir=__UpperCamelCase   ).read()
 _check_text_dataset(__UpperCamelCase				,     __UpperCamelCase   )
@pytest.mark.parametrize("""split"""				,     [None, NamedSplit("""train"""   ), """train""", """test"""]   )
def 	lowerCAmelCase    (       __UpperCamelCase				,     __UpperCamelCase				,     __UpperCamelCase   ):
 '''simple docstring'''





 UpperCAmelCase__       :	List[Any]        =       tmp_path / """cache"""
 UpperCAmelCase__       :	str        =       {"""text""": """string"""}
 UpperCAmelCase__       :	Dict        =       TextDatasetReader(__UpperCamelCase				,     cache_dir=__UpperCamelCase				,     split=__UpperCamelCase   ).read()
 _check_text_dataset(__UpperCamelCase				,     __UpperCamelCase   )
 assert dataset.split == split if split else "train"
@pytest.mark.parametrize("""path_type"""				,     [str, list]   )
def 	lowerCAmelCase    (       __UpperCamelCase				,     __UpperCamelCase				,     __UpperCamelCase   ):
 '''simple docstring'''





 if issubclass(__UpperCamelCase				,     __UpperCamelCase   ):
  UpperCAmelCase__       :	Union[str, Any]        =       text_path
 elif issubclass(__UpperCamelCase				,     __UpperCamelCase   ):
  UpperCAmelCase__       :	Tuple        =       [text_path]
 UpperCAmelCase__       :	Dict        =       tmp_path / """cache"""
 UpperCAmelCase__       :	Optional[Any]        =       {"""text""": """string"""}
 UpperCAmelCase__       :	Union[str, Any]        =       TextDatasetReader(__UpperCamelCase				,     cache_dir=__UpperCamelCase   ).read()
 _check_text_dataset(__UpperCamelCase				,     __UpperCamelCase   )
def 	lowerCAmelCase    (       __UpperCamelCase				,     __UpperCamelCase				,     __UpperCamelCase=("train",)   ):
 '''simple docstring'''





 assert isinstance(__UpperCamelCase				,     __UpperCamelCase   )
 for split in splits:
  UpperCAmelCase__       :	Any        =       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 	lowerCAmelCase    (       __UpperCamelCase				,     __UpperCamelCase				,     __UpperCamelCase   ):
 '''simple docstring'''





 UpperCAmelCase__       :	Any        =       tmp_path / """cache"""
 UpperCAmelCase__       :	Tuple        =       {"""text""": """string"""}
 with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
  UpperCAmelCase__       :	Dict        =       TextDatasetReader({"""train""": text_path}				,     cache_dir=__UpperCamelCase				,     keep_in_memory=__UpperCamelCase   ).read()
 _check_text_datasetdict(__UpperCamelCase				,     __UpperCamelCase   )
@pytest.mark.parametrize(
    """features"""				,     [
        None,
        {"""text""": """string"""},
        {"""text""": """int32"""},
        {"""text""": """float32"""},
    ]				,     )
def 	lowerCAmelCase    (       __UpperCamelCase				,     __UpperCamelCase				,     __UpperCamelCase   ):
 '''simple docstring'''





 UpperCAmelCase__       :	List[Any]        =       tmp_path / """cache"""
 # CSV file loses col_1 string dtype information: default now is "int64" instead of "string"
 UpperCAmelCase__       :	Optional[int]        =       {"""text""": """string"""}
 UpperCAmelCase__       :	Optional[Any]        =       features.copy() if features else default_expected_features
 UpperCAmelCase__       :	str        =       (
     Features({feature: Value(__UpperCamelCase   ) for feature, dtype in features.items()}   ) if features is not None else None
 )
 UpperCAmelCase__       :	Tuple        =       TextDatasetReader({"""train""": text_path}				,     features=__UpperCamelCase				,     cache_dir=__UpperCamelCase   ).read()
 _check_text_datasetdict(__UpperCamelCase				,     __UpperCamelCase   )




@pytest.mark.parametrize("""split"""				,     [None, NamedSplit("""train"""   ), """train""", """test"""]   )
def 	lowerCAmelCase    (       __UpperCamelCase				,     __UpperCamelCase				,     __UpperCamelCase   ):
 '''simple docstring'''





 if split:
  UpperCAmelCase__       :	Tuple        =       {split: text_path}
 else:
  UpperCAmelCase__       :	Optional[int]        =       """train"""
  UpperCAmelCase__       :	Optional[Any]        =       {"""train""": text_path, """test""": text_path}
 UpperCAmelCase__       :	List[str]        =       tmp_path / """cache"""
 UpperCAmelCase__       :	Optional[Any]        =       {"""text""": """string"""}
 UpperCAmelCase__       :	str        =       TextDatasetReader(__UpperCamelCase				,     cache_dir=__UpperCamelCase   ).read()
 _check_text_datasetdict(__UpperCamelCase				,     __UpperCamelCase				,     splits=list(path.keys()   )   )
 assert all(dataset[split].split == split for split in path.keys()   )










"""simple docstring"""







A		=						8.31_4462  # Unit - J mol-1 K-1

def  __SCREAMING_SNAKE_CASE		(			lowerCamelCase_:							float     ,		lowerCamelCase_:							float     ,		lowerCamelCase_:							float ):
						"""simple docstring"""






						if moles < 0 or kelvin < 0 or volume < 0:
												raise ValueError("Invalid inputs. Enter positive value." )
						return moles * kelvin * UNIVERSAL_GAS_CONSTANT / volume

def  __SCREAMING_SNAKE_CASE		(			lowerCamelCase_:							float     ,		lowerCamelCase_:							float     ,		lowerCamelCase_:							float ):
						"""simple docstring"""






						if moles < 0 or kelvin < 0 or pressure < 0:
												raise ValueError("Invalid inputs. Enter positive value." )
						return moles * kelvin * UNIVERSAL_GAS_CONSTANT / pressure


if __name__ == "__main__":
			from doctest import testmod

			testmod()



