




def SCREAMING_SNAKE_CASE       ( lowercase_		)     -> str:



       """simple docstring"""

       A__   				=					''''''
       for ch in key:
              if ch == " " or ch not in key_no_dups and ch.isalpha():
                     key_no_dups += ch
       return key_no_dups







def SCREAMING_SNAKE_CASE       ( lowercase_		)     -> dict[str, str]:



       """simple docstring"""

       A__   				=					[chr(i + 65		) for i in range(26		)]
       # Remove duplicate characters from key
       A__   				=					remove_duplicates(key.upper()		)
       A__   				=					len(lowercase_		)
       # First fill cipher with key characters
       A__   				=					{alphabet[i]: char for i, char in enumerate(lowercase_		)}
       # Then map remaining characters in alphabet to
       # the alphabet from the beginning
       for i in range(len(lowercase_		)				,       26		):
              A__   				=					alphabet[i - offset]
              # Ensure we are not mapping letters to letters previously mapped
              while char in key:
                     offset -= 1
                     A__   				=					alphabet[i - offset]
              A__   				=					char
       return cipher_alphabet







def SCREAMING_SNAKE_CASE       ( lowercase_				,       lowercase_		)     -> str:



       """simple docstring"""

       return "".join(cipher_map.get(lowercase_				,       lowercase_		) for ch in message.upper()		)







def SCREAMING_SNAKE_CASE       ( lowercase_				,       lowercase_		)     -> str:



       """simple docstring"""

       A__   				=					{v: k for k, v in cipher_map.items()}
       return "".join(rev_cipher_map.get(lowercase_				,       lowercase_		) for ch in message.upper()		)







def SCREAMING_SNAKE_CASE       ( )     -> None:



       """simple docstring"""

       A__   				=					input('''Enter message to encode or decode: '''		).strip()
       A__   				=					input('''Enter keyword: '''		).strip()
       A__   				=					input('''Encipher or decipher? E/D:'''		).strip()[0].lower()
       try:
              A__   				=					{'''e''': encipher, '''d''': decipher}[option]
       except KeyError:
              raise KeyError('''invalid input option'''		)
       A__   				=					create_cipher_map(lowercase_		)
       print(func(lowercase_				,       lowercase_		)		)


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  main()





import pyarrow.parquet as pq
import pytest

from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config
from datasets.features.image import Image
from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size

from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases







def SCREAMING_SNAKE_CASE       ( lowercase_				,       lowercase_		)     -> Tuple:



       """simple docstring"""

       assert isinstance(lowercase_				,       lowercase_		)
       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 SCREAMING_SNAKE_CASE       ( lowercase_				,       lowercase_				,       lowercase_		)     -> int:



       """simple docstring"""

       A__   				=					tmp_path / '''cache'''
       A__   				=					{'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
       with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
              A__   				=					ParquetDatasetReader(lowercase_				,       cache_dir=lowercase_				,       keep_in_memory=lowercase_		).read()
       _check_parquet_dataset(lowercase_				,       lowercase_		)







@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 SCREAMING_SNAKE_CASE       ( lowercase_				,       lowercase_				,       lowercase_		)     -> List[str]:



       """simple docstring"""

       A__   				=					tmp_path / '''cache'''
       A__   				=					{'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
       A__   				=					features.copy() if features else default_expected_features
       A__   				=					(
           Features({feature: Value(lowercase_		) for feature, dtype in features.items()}		) if features is not None else None
       )
       A__   				=					ParquetDatasetReader(lowercase_				,       features=lowercase_				,       cache_dir=lowercase_		).read()
       _check_parquet_dataset(lowercase_				,       lowercase_		)







@pytest.mark.parametrize('''split'''				,       [None, NamedSplit('''train'''		), '''train''', '''test''']		)
def SCREAMING_SNAKE_CASE       ( lowercase_				,       lowercase_				,       lowercase_		)     -> str:



       """simple docstring"""

       A__   				=					tmp_path / '''cache'''
       A__   				=					{'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
       A__   				=					ParquetDatasetReader(lowercase_				,       cache_dir=lowercase_				,       split=lowercase_		).read()
       _check_parquet_dataset(lowercase_				,       lowercase_		)
       assert dataset.split == split if split else "train"







@pytest.mark.parametrize('''path_type'''				,       [str, list]		)
def SCREAMING_SNAKE_CASE       ( lowercase_				,       lowercase_				,       lowercase_		)     -> List[Any]:



       """simple docstring"""

       if issubclass(lowercase_				,       lowercase_		):
              A__   				=					parquet_path
       elif issubclass(lowercase_				,       lowercase_		):
              A__   				=					[parquet_path]
       A__   				=					tmp_path / '''cache'''
       A__   				=					{'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
       A__   				=					ParquetDatasetReader(lowercase_				,       cache_dir=lowercase_		).read()
       _check_parquet_dataset(lowercase_				,       lowercase_		)







def SCREAMING_SNAKE_CASE       ( lowercase_				,       lowercase_				,       lowercase_=("train",)		)     -> List[str]:



       """simple docstring"""

       assert isinstance(lowercase_				,       lowercase_		)
       for split in splits:
              A__   				=					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 SCREAMING_SNAKE_CASE       ( lowercase_				,       lowercase_				,       lowercase_		)     -> str:



       """simple docstring"""

       A__   				=					tmp_path / '''cache'''
       A__   				=					{'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
       with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
              A__   				=					ParquetDatasetReader(
                  {'''train''': parquet_path}				,       cache_dir=lowercase_				,       keep_in_memory=lowercase_		).read()
       _check_parquet_datasetdict(lowercase_				,       lowercase_		)







@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 SCREAMING_SNAKE_CASE       ( lowercase_				,       lowercase_				,       lowercase_		)     -> List[Any]:



       """simple docstring"""

       A__   				=					tmp_path / '''cache'''
       A__   				=					{'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
       A__   				=					features.copy() if features else default_expected_features
       A__   				=					(
           Features({feature: Value(lowercase_		) for feature, dtype in features.items()}		) if features is not None else None
       )
       A__   				=					ParquetDatasetReader({'''train''': parquet_path}				,       features=lowercase_				,       cache_dir=lowercase_		).read()
       _check_parquet_datasetdict(lowercase_				,       lowercase_		)







@pytest.mark.parametrize('''split'''				,       [None, NamedSplit('''train'''		), '''train''', '''test''']		)
def SCREAMING_SNAKE_CASE       ( lowercase_				,       lowercase_				,       lowercase_		)     -> Union[str, Any]:



       """simple docstring"""

       if split:
              A__   				=					{split: parquet_path}
       else:
              A__   				=					'''train'''
              A__   				=					{'''train''': parquet_path, '''test''': parquet_path}
       A__   				=					tmp_path / '''cache'''
       A__   				=					{'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
       A__   				=					ParquetDatasetReader(lowercase_				,       cache_dir=lowercase_		).read()
       _check_parquet_datasetdict(lowercase_				,       lowercase_				,       splits=list(path.keys()		)		)
       assert all(dataset[split].split == split for split in path.keys()		)







def SCREAMING_SNAKE_CASE       ( lowercase_				,       lowercase_		)     -> List[str]:



       """simple docstring"""

       A__   				=					ParquetDatasetWriter(lowercase_				,       tmp_path / '''foo.parquet'''		)
       assert writer.write() > 0
       A__   				=					pq.ParquetFile(tmp_path / '''foo.parquet'''		)
       A__   				=					pf.read()
       assert dataset.data.table == output_table







def SCREAMING_SNAKE_CASE       ( lowercase_				,       lowercase_		)     -> str:



       """simple docstring"""

       A__   				=					str(shared_datadir / '''test_image_rgb.jpg'''		)
       A__   				=					{'''image''': [image_path]}
       A__   				=					Features({'''image''': Image()}		)
       A__   				=					Dataset.from_dict(lowercase_				,       features=lowercase_		)
       A__   				=					ParquetDatasetWriter(lowercase_				,       tmp_path / '''foo.parquet'''		)
       assert writer.write() > 0

       A__   				=					Dataset.from_parquet(str(tmp_path / '''foo.parquet'''		)		)
       assert dataset.features == reloaded_dataset.features

       A__   				=					ParquetDatasetReader(str(tmp_path / '''foo.parquet'''		)				,       streaming=lowercase_		).read()
       assert dataset.features == reloaded_iterable_dataset.features







@pytest.mark.parametrize(
    '''feature, expected'''				,       [
        (Features({'''foo''': Value('''int32'''		)}		), None),
        (Features({'''image''': Image(), '''foo''': Value('''int32'''		)}		), config.PARQUET_ROW_GROUP_SIZE_FOR_IMAGE_DATASETS),
        (Features({'''nested''': Sequence(Audio()		)}		), config.PARQUET_ROW_GROUP_SIZE_FOR_AUDIO_DATASETS),
    ]				,       )
def SCREAMING_SNAKE_CASE       ( lowercase_				,       lowercase_		)     -> Tuple:



       """simple docstring"""

       assert get_writer_batch_size(lowercase_		) == expected


