






'''simple docstring'''
import itertools
from dataclasses import dataclass
from typing import List, Optional

import pyarrow as pa
import pyarrow.parquet as pq

import datasets
from datasets.table import table_cast


a_					=	datasets.utils.logging.get_logger(__name__)






@dataclass
class        __SCREAMING_SNAKE_CASE (     datasets.BuilderConfig			):
 snake_case_												=							1_0000
 snake_case_												=							None
 snake_case_												=							None






class        __SCREAMING_SNAKE_CASE (     datasets.ArrowBasedBuilder			):
 snake_case_												=							ParquetConfig




 def        __magic_name__		( self		:							str )		->  Any:
       return datasets.DatasetInfo(features=self.config.features )




 def        __magic_name__		( self		:							Union[str, Any]   , __lowercase		:							List[str] )		->  Union[str, Any]:
       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}" )
       SCREAMING_SNAKE_CASE__       :			Optional[int]													=dl_manager.download_and_extract(self.config.data_files )
       if isinstance(__lowercase   , (str, list, tuple) ):
             SCREAMING_SNAKE_CASE__       :			Optional[Any]													=data_files
             if isinstance(__lowercase   , __lowercase ):
                   SCREAMING_SNAKE_CASE__       :			Optional[int]													=[files]
             # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
             SCREAMING_SNAKE_CASE__       :			Optional[Any]													=[dl_manager.iter_files(__lowercase ) for file in files]
             return [datasets.SplitGenerator(name=datasets.Split.TRAIN   , gen_kwargs={'''files''': files} )]
       SCREAMING_SNAKE_CASE__       :			str													=[]
       for split_name, files in data_files.items():
             if isinstance(__lowercase   , __lowercase ):
                   SCREAMING_SNAKE_CASE__       :			Optional[int]													=[files]
             # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
             SCREAMING_SNAKE_CASE__       :			Any													=[dl_manager.iter_files(__lowercase ) for file in files]
             # Infer features is they are stoed in the arrow schema
             if self.info.features is None:
                   for file in itertools.chain.from_iterable(__lowercase ):
                         with open(__lowercase   , '''rb''' ) as f:
                               SCREAMING_SNAKE_CASE__       :			Optional[int]													=datasets.Features.from_arrow_schema(pq.read_schema(__lowercase ) )
                         break
             splits.append(datasets.SplitGenerator(name=__lowercase   , gen_kwargs={'''files''': files} ) )
       return splits




 def        __magic_name__		( self		:							Tuple   , __lowercase		:							pa.Table )		->  pa.Table:
       if self.info.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
             SCREAMING_SNAKE_CASE__       :			List[str]													=table_cast(__lowercase   , self.info.features.arrow_schema )
       return pa_table




 def        __magic_name__		( self		:							Optional[int]   , __lowercase		:							Any )		->  List[Any]:
       SCREAMING_SNAKE_CASE__       :			List[str]													=self.info.features.arrow_schema if self.info.features is not None else None
       if self.info.features is not None and self.config.columns is not None:
             if sorted(field.name for field in schema ) != sorted(self.config.columns ):
                   raise ValueError(
                       F"Tried to load parquet data with columns '{self.config.columns}' with mismatching features '{self.info.features}'" )
       for file_idx, file in enumerate(itertools.chain.from_iterable(__lowercase ) ):
             with open(__lowercase   , '''rb''' ) as f:
                   SCREAMING_SNAKE_CASE__       :			Union[str, Any]													=pq.ParquetFile(__lowercase )
                   try:
                         for batch_idx, record_batch in enumerate(
                             parquet_file.iter_batches(batch_size=self.config.batch_size   , columns=self.config.columns ) ):
                               SCREAMING_SNAKE_CASE__       :			Union[str, Any]													=pa.Table.from_batches([record_batch] )
                               # Uncomment for debugging (will print the Arrow table size and elements)
                               # logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
                               # logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
                               yield F"{file_idx}_{batch_idx}", self._cast_table(__lowercase )
                   except ValueError as e:
                         logger.error(F"Failed to read file '{file}' with error {type(__lowercase )}: {e}" )
                         raise







'''simple docstring'''
from decimal import Decimal, getcontext
from math import ceil, factorial





def 	_a(					UpperCamelCase__			:  int							):




      '''simple docstring'''






      if not isinstance(UpperCamelCase__,		UpperCamelCase__							):
            raise TypeError('''Undefined for non-integers'''							)
      elif precision < 1:
            raise ValueError('''Undefined for non-natural numbers'''							)

      SCREAMING_SNAKE_CASE__       :			Optional[Any]													=precision
      SCREAMING_SNAKE_CASE__       :			int													=ceil(precision / 1_4							)
      SCREAMING_SNAKE_CASE__       :			int													=4_2_6_8_8_0 * Decimal(1_0_0_0_5							).sqrt()
      SCREAMING_SNAKE_CASE__       :			Tuple													=1
      SCREAMING_SNAKE_CASE__       :			Any													=1_3_5_9_1_4_0_9
      SCREAMING_SNAKE_CASE__       :			List[Any]													=Decimal(UpperCamelCase__							)
      for k in range(1,		UpperCamelCase__							):
            SCREAMING_SNAKE_CASE__       :			str													=factorial(6 * k							) // (factorial(3 * k							) * factorial(UpperCamelCase__							) ** 3)
            linear_term += 5_4_5_1_4_0_1_3_4
            exponential_term *= -2_6_2_5_3_7_4_1_2_6_4_0_7_6_8_0_0_0
            partial_sum += Decimal(multinomial_term * linear_term							) / exponential_term
      return str(constant_term / partial_sum							)[:-1]


if __name__ == "__main__":
  a_					=	5_0
  print(F'''The first {n} digits of pi is: {pi(n)}''')