





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   ):
			'''simple docstring'''




			__lowerCamelCase     :	Optional[datasets.Features]          =   None


class   A      (datasets.ArrowBasedBuilder   ):
			'''simple docstring'''




			__lowerCamelCase     :	Any          =   PandasConfig






			def        a_	(      self       :   int       )     ->     Any:







					"""simple docstring"""






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






			def        a_	(      self       :   List[str]							,     __lowerCAmelCase       :   Tuple       )     ->     List[Any]:







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






			def        a_	(      self       :   Optional[int]							,     __lowerCAmelCase       :   List[Any]       )     ->     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
							A__  				=       table_cast(_a							,     self.config.features.arrow_schema       )
					return pa_table







			def        a_	(      self       :   List[Any]							,     __lowerCAmelCase       :   List[str]       )     ->     List[str]:







					"""simple docstring"""






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










def        __lowerCamelCase (							__a       :float   ,					__a       :list[float]   )		->    float:






		"""simple docstring"""

		if discount_rate < 0:
				raise ValueError("""Discount rate cannot be negative"""   )
		if not cash_flows:
				raise ValueError("""Cash flows list cannot be empty"""   )
		A__  				=       sum(
		    cash_flow / ((1 + discount_rate) ** i) for i, cash_flow in enumerate(__a   )   )
		return round(__a   ,					ndigits=2   )


if __name__ == "__main__":
					import doctest

					doctest.testmod()



