






"""simple docstring"""

import itertools
from dataclasses import dataclass
from typing import Optional

import pandas as pd
import pyarrow as pa

import datasets
from datasets.table import table_cast

@dataclass
class 						A_							(      datasets.BuilderConfig  ):
				UpperCAmelCase__        =				None





class 						A_							(      datasets.ArrowBasedBuilder  ):
				UpperCAmelCase__        =				PandasConfig







				def     _snake_case					(							self							:						Union[str, Any]	)				->					List[Any]:
										return datasets.DatasetInfo(features=self.config.features	)







				def     _snake_case					(							self							:						Dict						,    __lowerCamelCase							:						List[Any]	)				->					List[str]:
										if not self.config.data_files:
																raise ValueError(f'''At least one data file must be specified, but got data_files={self.config.data_files}'''	)
										__magic_name__            =     dl_manager.download_and_extract(self.config.data_files	)
										if isinstance(__lowerCamelCase						,    (str, list, tuple)	):
																__magic_name__            =     data_files
																if isinstance(__lowerCamelCase						,    __lowerCamelCase	):
																						__magic_name__            =     [files]
																# Use `dl_manager.iter_files` to skip hidden files in an extracted archive
																__magic_name__            =     [dl_manager.iter_files(__lowerCamelCase	) for file in files]
																return [datasets.SplitGenerator(name=datasets.Split.TRAIN						,    gen_kwargs={"files": files}	)]
										__magic_name__            =     []
										for split_name, files in data_files.items():
																if isinstance(__lowerCamelCase						,    __lowerCamelCase	):
																						__magic_name__            =     [files]
																# Use `dl_manager.iter_files` to skip hidden files in an extracted archive
																__magic_name__            =     [dl_manager.iter_files(__lowerCamelCase	) for file in files]
																splits.append(datasets.SplitGenerator(name=__lowerCamelCase						,    gen_kwargs={"files": files}	)	)
										return splits







				def     _snake_case					(							self							:						List[Any]						,    __lowerCamelCase							:						pa.Table	)				->					pa.Table:
										if self.config.features is not None:
																# more expensive cast to support nested features with keys in a different order
																# allows str <-> int/float or str to Audio for example
																__magic_name__            =     table_cast(__lowerCamelCase						,    self.config.features.arrow_schema	)
										return pa_table







				def     _snake_case					(							self							:						int						,    __lowerCamelCase							:						List[Any]	)				->					Dict:
										for i, file in enumerate(itertools.chain.from_iterable(__lowerCamelCase	)	):
																with open(__lowerCamelCase						,    "rb"	) as f:
																						__magic_name__            =     pa.Table.from_pandas(pd.read_pickle(__lowerCamelCase	)	)
																						yield i, self._cast_table(__lowerCamelCase	)











"""simple docstring"""

def _lowerCAmelCase	(  __lowerCamelCase:int   ):

						'''simple docstring'''






						if number < 0:
												raise ValueError("number must not be negative"   )
						return number & (number - 1) == 0


if __name__ == "__main__":
			import doctest

			doctest.testmod()



