






'''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 							_UpperCAmelCase    (		datasets.BuilderConfig      ):
    __lowerCamelCase: Optional[datasets.Features]									=     None


class 							_UpperCAmelCase    (		datasets.ArrowBasedBuilder      ):
    __lowerCamelCase: int									=     PandasConfig




    def 					lowerCAmelCase__					(      self	:							List[Any]      ):






       '''simple docstring'''






       return datasets.DatasetInfo(features=self.config.features      )




    def 					lowerCAmelCase__					(      self	:							Optional[Any]	,  a	:							Dict      ):






       '''simple docstring'''






       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}"""      )
       lowercase_						:     Union[str, Any]							     =  dl_manager.download_and_extract(self.config.data_files      )
       if isinstance(a	,  (str, list, tuple)      ):
          lowercase_						:     Dict							     =  data_files
          if isinstance(a	,  a      ):
             lowercase_						:     List[Any]							     =  [files]
          # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
          lowercase_						:     Optional[int]							     =  [dl_manager.iter_files(a      ) for file in files]
          return [datasets.SplitGenerator(name=datasets.Split.TRAIN	,  gen_kwargs={"files": files}      )]
       lowercase_						:     Optional[Any]							     =  []
       for split_name, files in data_files.items():
          if isinstance(a	,  a      ):
             lowercase_						:     int							     =  [files]
          # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
          lowercase_						:     Dict							     =  [dl_manager.iter_files(a      ) for file in files]
          splits.append(datasets.SplitGenerator(name=a	,  gen_kwargs={"files": files}      )      )
       return splits




    def 					lowerCAmelCase__					(      self	:							Tuple	,  a	:							pa.Table      ):






       '''simple docstring'''






       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
          lowercase_						:     Tuple							     =  table_cast(a	,  self.config.features.arrow_schema      )
       return pa_table





    def 					lowerCAmelCase__					(      self	:							str	,  a	:							Dict      ):






       '''simple docstring'''






       for i, file in enumerate(itertools.chain.from_iterable(a      )      ):
          with open(a	,  "rb"      ) as f:
             lowercase_						:     int							     =  pa.Table.from_pandas(pd.read_pickle(a      )      )
             yield i, self._cast_table(a      )












'''simple docstring'''
from __future__ import annotations




def 		__SCREAMING_SNAKE_CASE       (	_UpperCamelCase				):


   """simple docstring"""




   lowercase_						:     Optional[int]							     =  2
   lowercase_						:     Tuple							     =  []
   while i * i <= n:
      if n % i:
         i += 1
      else:
         n //= i
         factors.append(_UpperCamelCase				)
   if n > 1:
      factors.append(_UpperCamelCase				)
   return factors


if __name__ == "__main__":
 import doctest

 doctest.testmod()




