



"""simple docstring"""
from unittest import TestCase

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



class       SCREAMING_SNAKE_CASE__  (					UpperCAmelCase__ ):

   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      Union[str, 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 	SCREAMING_SNAKE_CASE     (   self						)  ->      Union[str, Any]:





    '''simple docstring'''




    UpperCAmelCase	:					List[Any]	=	{"""col_1""": [3, 2, 1, 0], """col_2""": ["""a""", """b""", """c""", """d"""]}
    return Dataset.from_dict(_SCREAMING_SNAKE_CASE						)

   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      Dict:





    '''simple docstring'''




    UpperCAmelCase	:					Any	=	self._create_example_records()
    UpperCAmelCase	:					int	=	Dataset.from_list(_SCREAMING_SNAKE_CASE						)
    self.assertListEqual(dset.column_names      ,     ["""col_1""", """col_2"""]						)
    for i, r in enumerate(_SCREAMING_SNAKE_CASE						):
     self.assertDictEqual(_SCREAMING_SNAKE_CASE      ,     example_records[i]						)

   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      Union[str, Any]:





    '''simple docstring'''




    UpperCAmelCase	:					List[str]	=	self._create_example_records()
    UpperCAmelCase	:					List[str]	=	Dataset.from_list(_SCREAMING_SNAKE_CASE						)
    UpperCAmelCase	:					List[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 	SCREAMING_SNAKE_CASE     (   self						)  ->      Optional[Any]:  # checks what happens with missing columns





    '''simple docstring'''




    UpperCAmelCase	:					Optional[int]	=	[{"""col_1""": 1}, {"""col_2""": """x"""}]
    UpperCAmelCase	:					List[str]	=	Dataset.from_list(_SCREAMING_SNAKE_CASE						)
    self.assertDictEqual(dset[0]      ,     {"""col_1""": 1}						)
    self.assertDictEqual(dset[1]      ,     {"""col_1""": None}						)  # NB: first record is used for columns

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





    '''simple docstring'''




    UpperCAmelCase	:					Union[str, Any]	=	[{"""col_1""": []}, {"""col_1""": [1, 2]}]
    UpperCAmelCase	:					List[Any]	=	Dataset.from_list(_SCREAMING_SNAKE_CASE						)
    self.assertEqual(dset.info.features["""col_1"""]      ,     Sequence(Value("""int64"""						)						)						)




   def 	SCREAMING_SNAKE_CASE     (   self						)  ->      Optional[int]:





    '''simple docstring'''




    UpperCAmelCase	:					Dict	=	Dataset.from_list([]						)
    self.assertEqual(len(_SCREAMING_SNAKE_CASE						)      ,     0						)
    self.assertListEqual(dset.column_names      ,     []						)





"""simple docstring"""
from collections.abc import Callable

import numpy as np

def       _snake_case						(						UpperCamelCase						:		Callable			,		UpperCamelCase						:		float			,		UpperCamelCase						:		float			,		UpperCamelCase						:		float			,		UpperCamelCase						:		float						):
 UpperCAmelCase	:					Any	=	int(np.ceil((x_end - xa) / step_size						)						)
 UpperCAmelCase	:					Optional[Any]	=	np.zeros((n + 1,)						)
 UpperCAmelCase	:					Optional[int]	=	ya
 UpperCAmelCase	:					int	=	xa

 for k in range(UpperCamelCase						):
  UpperCAmelCase	:					Optional[int]	=	y[k] + step_size * ode_func(UpperCamelCase			,		y[k]						)
  UpperCAmelCase	:					Optional[int]	=	y[k] + (
      (step_size / 2) * (ode_func(UpperCamelCase			,		y[k]						) + ode_func(x + step_size			,		UpperCamelCase						))
  )
  x += step_size

 return y


if __name__ == "__main__":
      import doctest

      doctest.testmod()
