
"""simple docstring"""







import itertools
from dataclasses import dataclass
from typing import Optional

import pyarrow as pa

import datasets
from datasets.table import table_cast


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



@dataclass
class 		UpperCAmelCase_	(datasets.BuilderConfig						):
       """simple docstring"""




       UpperCamelCase_						:     Optional[datasets.Features]				   =    None



class 		UpperCAmelCase_	(datasets.ArrowBasedBuilder						):
       """simple docstring"""




       UpperCamelCase_						:     Any				   =    ArrowConfig




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



            """simple docstring"""

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




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



            """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}''' )
            UpperCAmelCase_						:    Any    					=  dl_manager.download_and_extract(self.config.data_files )
            if isinstance(a_     ,   (str, list, tuple) ):
                 UpperCAmelCase_						:    Tuple    					=  data_files
                 if isinstance(a_     ,   a_ ):
                      UpperCAmelCase_						:    List[str]    					=  [files]
                 # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
                 UpperCAmelCase_						:    Optional[Any]    					=  [dl_manager.iter_files(a_ ) for file in files]
                 return [datasets.SplitGenerator(name=datasets.Split.TRAIN     ,   gen_kwargs={"""files""": files} )]
            UpperCAmelCase_						:    Optional[int]    					=  []
            for split_name, files in data_files.items():
                 if isinstance(a_     ,   a_ ):
                      UpperCAmelCase_						:    Optional[int]    					=  [files]
                 # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
                 UpperCAmelCase_						:    Any    					=  [dl_manager.iter_files(a_ ) 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(a_ ):
                           with open(a_     ,   """rb""" ) as f:
                                UpperCAmelCase_						:    List[str]    					=  datasets.Features.from_arrow_schema(pa.ipc.open_stream(a_ ).schema )
                           break
                 splits.append(datasets.SplitGenerator(name=a_     ,   gen_kwargs={"""files""": files} ) )
            return splits




       def   a      ( self       : Union[str, Any]     ,   a_       : pa.Table )->					pa.Table:



            """simple docstring"""

            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
                 UpperCAmelCase_						:    List[Any]    					=  table_cast(a_     ,   self.info.features.arrow_schema )
            return pa_table






       def   a      ( self       : List[str]     ,   a_       : Tuple )->					Dict:



            """simple docstring"""

            for file_idx, file in enumerate(itertools.chain.from_iterable(a_ ) ):
                 with open(a_     ,   """rb""" ) as f:
                      try:
                           for batch_idx, record_batch in enumerate(pa.ipc.open_stream(a_ ) ):
                                UpperCAmelCase_						:    Tuple    					=  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(a_ )
                      except ValueError as e:
                           logger.error(f'''Failed to read file \'{file}\' with error {type(a_ )}: {e}''' )
                           raise



"""simple docstring"""







from math import radians as angle_to_radians
from math import sin

# Acceleration Constant on Earth (unit m/s^2)
lowercase_						    =					9.8_0665




def 			A_			(					lowercase						, lowercase      )     ->							None:


     """simple docstring"""







     if not isinstance(lowercase						, (int, float)      ):
          raise TypeError("""Invalid velocity. Should be a positive number."""      )

     if not isinstance(lowercase						, (int, float)      ):
          raise TypeError("""Invalid angle. Range is 1-90 degrees."""      )

     # Ensure valid angle
     if angle > 90 or angle < 1:
          raise ValueError("""Invalid angle. Range is 1-90 degrees."""      )

     # Ensure valid velocity
     if init_velocity < 0:
          raise ValueError("""Invalid velocity. Should be a positive number."""      )




def 			A_			(					lowercase						, lowercase      )     ->							float:


     """simple docstring"""







     check_args(lowercase						, lowercase      )
     UpperCAmelCase_						:    Any    					=  angle_to_radians(2 * angle      )
     return round(init_velocity**2 * sin(lowercase      ) / g						, 2      )




def 			A_			(					lowercase						, lowercase      )     ->							float:


     """simple docstring"""







     check_args(lowercase						, lowercase      )
     UpperCAmelCase_						:    Union[str, Any]    					=  angle_to_radians(lowercase      )
     return round(init_velocity**2 * sin(lowercase      ) ** 2 / (2 * g)						, 2      )




def 			A_			(					lowercase						, lowercase      )     ->							float:


     """simple docstring"""







     check_args(lowercase						, lowercase      )
     UpperCAmelCase_						:    Optional[int]    					=  angle_to_radians(lowercase      )
     return round(2 * init_velocity * sin(lowercase      ) / g						, 2      )




def 			A_			(					)     ->							None:


     """simple docstring"""







     UpperCAmelCase_					,UpperCAmelCase_						:    Optional[int]    					=  25, 20
     assert horizontal_distance(lowercase						, lowercase      ) == 40.97
     assert max_height(lowercase						, lowercase      ) == 3.73
     assert total_time(lowercase						, lowercase      ) == 1.74


if __name__ == "__main__":
       from doctest import testmod

       testmod()

       # Get input from user
       lowercase_						    =					float(input("Initial Velocity: ").strip())

       # Get input from user
       lowercase_						    =					float(input("angle: ").strip())

       # Print results
       print()
       print("Results: ")
       print(f"""Horizontal Distance: {horizontal_distance(init_vel, angle)!s} [m]""")
       print(f"""Maximum Height: {max_height(init_vel, angle)!s} [m]""")
       print(f"""Total Time: {total_time(init_vel, angle)!s} [s]""")

