





from unittest import TestCase

from datasets import Sequence, Value
from datasets.arrow_dataset import Dataset





class  A__    (							__UpperCAmelCase	):




   """simple docstring"""



   def 							__lowercase		(					self)			->						Optional[Any]:







          '''simple docstring'''

          return [
              {"col_1": 3, "col_2": "a"},
              {"col_1": 2, "col_2": "b"},
              {"col_1": 1, "col_2": "c"},
              {"col_1": 0, "col_2": "d"},
          ]

   def 							__lowercase		(					self)			->						List[Any]:







          '''simple docstring'''

          a__						:	str =				{'col_1': [3, 2, 1, 0], 'col_2': ['a', 'b', 'c', 'd']}
          return Dataset.from_dict(lowercase)

   def 							__lowercase		(					self)			->						int:







          '''simple docstring'''

          a__						:	Optional[Any] =				self._create_example_records()
          a__						:	Dict =				Dataset.from_list(lowercase)
          self.assertListEqual(dset.column_names					,  ['col_1', 'col_2'])
          for i, r in enumerate(lowercase):
                 self.assertDictEqual(lowercase					,  example_records[i])

   def 							__lowercase		(					self)			->						List[Any]:







          '''simple docstring'''

          a__						:	Any =				self._create_example_records()
          a__						:	Optional[int] =				Dataset.from_list(lowercase)
          a__						:	str =				Dataset.from_dict({k: [r[k] for r in example_records] for k in example_records[0]})
          self.assertEqual(dset.info					,  dset_from_dict.info)

   def 							__lowercase		(					self)			->						Optional[int]:  # checks what happens with missing columns







          '''simple docstring'''

          a__						:	int =				[{'col_1': 1}, {'col_2': 'x'}]
          a__						:	int =				Dataset.from_list(lowercase)
          self.assertDictEqual(dset[0]					,  {'col_1': 1})
          self.assertDictEqual(dset[1]					,  {'col_1': None})  # NB: first record is used for columns

   def 							__lowercase		(					self)			->						int:  # checks if the type can be inferred from the second record







          '''simple docstring'''

          a__						:	Union[str, Any] =				[{'col_1': []}, {'col_1': [1, 2]}]
          a__						:	Any =				Dataset.from_list(lowercase)
          self.assertEqual(dset.info.features['col_1']					,  Sequence(Value('int64')))

   def 							__lowercase		(					self)			->						List[Any]:







          '''simple docstring'''

          a__						:	List[str] =				Dataset.from_list([])
          self.assertEqual(len(lowercase)					,  0)
          self.assertListEqual(dset.column_names					,  [])









"""simple docstring"""





def  __A   (_SCREAMING_SNAKE_CASE     ,   _SCREAMING_SNAKE_CASE			)					->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'			)
  lowerCAmelCase__			:Union[str, Any]											=							sum(
      cash_flow / ((1 + discount_rate) ** i) for i, cash_flow in enumerate(_SCREAMING_SNAKE_CASE			)			)
  return round(_SCREAMING_SNAKE_CASE     ,   ndigits=2			)


if __name__ == "__main__":
  import doctest

  doctest.testmod()
