






"""simple docstring"""






import multiprocessing
import os
from typing import BinaryIO, Optional, Union

from .. import Dataset, Features, NamedSplit, config
from ..formatting import query_table
from ..packaged_modules.csv.csv import Csv
from ..utils import logging
from ..utils.typing import NestedDataStructureLike, PathLike
from .abc import AbstractDatasetReader
class 						__lowerCAmelCase   (			UpperCAmelCase       ):







  '''simple docstring'''


  def __init__(      self:		List[str]				,			UpperCamelCase_:		NestedDataStructureLike[PathLike]				,			UpperCamelCase_:		Optional[NamedSplit] = None				,			UpperCamelCase_:		Optional[Features] = None				,			UpperCamelCase_:		str = None				,			UpperCamelCase_:		bool = False				,			UpperCamelCase_:		bool = False				,			UpperCamelCase_:		Optional[int] = None				,			**UpperCamelCase_:		Dict				,			):
        super().__init__(
            UpperCamelCase_				,			split=UpperCamelCase_				,			features=UpperCamelCase_				,			cache_dir=UpperCamelCase_				,			keep_in_memory=UpperCamelCase_				,			streaming=UpperCamelCase_				,			num_proc=UpperCamelCase_				,			**UpperCamelCase_				,			)
        UpperCamelCase_     =path_or_paths if isinstance(UpperCamelCase_				,			UpperCamelCase_					) else {self.split: path_or_paths}
        UpperCamelCase_     =Csv(
            cache_dir=UpperCamelCase_				,			data_files=UpperCamelCase_				,			features=UpperCamelCase_				,			**UpperCamelCase_				,			)





  def 					UpperCamelCase__   (      self:		int					):
        # Build iterable dataset
        if self.streaming:
              UpperCamelCase_     =self.builder.as_streaming_dataset(split=self.split					)
        # Build regular (map-style) dataset
        else:
              UpperCamelCase_     =None
              UpperCamelCase_     =None
              UpperCamelCase_     =None
              UpperCamelCase_     =None

              self.builder.download_and_prepare(
                  download_config=UpperCamelCase_				,			download_mode=UpperCamelCase_				,			verification_mode=UpperCamelCase_				,			base_path=UpperCamelCase_				,			num_proc=self.num_proc				,			)
              UpperCamelCase_     =self.builder.as_dataset(
                  split=self.split				,			verification_mode=UpperCamelCase_				,			in_memory=self.keep_in_memory					)
        return dataset




class 						__lowerCAmelCase   :







  '''simple docstring'''


  def __init__(      self:		Tuple				,			UpperCamelCase_:		Dataset				,			UpperCamelCase_:		Union[PathLike, BinaryIO]				,			UpperCamelCase_:		Optional[int] = None				,			UpperCamelCase_:		Optional[int] = None				,			**UpperCamelCase_:		Dict				,			):
        if num_proc is not None and num_proc <= 0:
              raise ValueError(f"""num_proc {num_proc} must be an integer > 0."""					)

        UpperCamelCase_     =dataset
        UpperCamelCase_     =path_or_buf
        UpperCamelCase_     =batch_size if batch_size else config.DEFAULT_MAX_BATCH_SIZE
        UpperCamelCase_     =num_proc
        UpperCamelCase_     ="utf-8"
        UpperCamelCase_     =to_csv_kwargs
  def 					UpperCamelCase__   (      self:		Optional[Any]					):
        UpperCamelCase_     =self.to_csv_kwargs.pop("path_or_buf"				,			UpperCamelCase_					)
        UpperCamelCase_     =self.to_csv_kwargs.pop("header"				,			UpperCamelCase_					)
        UpperCamelCase_     =self.to_csv_kwargs.pop("index"				,			UpperCamelCase_					)

        if isinstance(self.path_or_buf				,			(str, bytes, os.PathLike)					):
              with open(self.path_or_buf				,			"wb+"					) as buffer:
                    UpperCamelCase_     =self._write(file_obj=UpperCamelCase_				,			header=UpperCamelCase_				,			index=UpperCamelCase_				,			**self.to_csv_kwargs					)
        else:
              UpperCamelCase_     =self._write(file_obj=self.path_or_buf				,			header=UpperCamelCase_				,			index=UpperCamelCase_				,			**self.to_csv_kwargs					)
        return written
  def 					UpperCamelCase__   (      self:		List[str]				,			UpperCamelCase_:		Optional[Any]					):
        UpperCamelCase_    ,							UpperCamelCase_    ,							UpperCamelCase_    ,							UpperCamelCase_     =args

        UpperCamelCase_     =query_table(
            table=self.dataset.data				,			key=slice(UpperCamelCase_				,			offset + self.batch_size					)				,			indices=self.dataset._indices				,			)
        UpperCamelCase_     =batch.to_pandas().to_csv(
            path_or_buf=UpperCamelCase_				,			header=header if (offset == 0) else False				,			index=UpperCamelCase_				,			**UpperCamelCase_					)
        return csv_str.encode(self.encoding					)





  def 					UpperCamelCase__   (      self:		Tuple				,			UpperCamelCase_:		BinaryIO				,			UpperCamelCase_:		Dict				,			UpperCamelCase_:		Optional[int]				,			**UpperCamelCase_:		Union[str, Any]					):
        UpperCamelCase_     =0

        if self.num_proc is None or self.num_proc == 1:
              for offset in logging.tqdm(
                  range(0				,			len(self.dataset					)				,			self.batch_size					)				,			unit="ba"				,			disable=not logging.is_progress_bar_enabled()				,			desc="Creating CSV from Arrow format"				,			):
                    UpperCamelCase_     =self._batch_csv((offset, header, index, to_csv_kwargs)					)
                    written += file_obj.write(UpperCamelCase_					)

        else:
              UpperCamelCase_    ,							UpperCamelCase_     =len(self.dataset					), self.batch_size
              with multiprocessing.Pool(self.num_proc					) as pool:
                    for csv_str in logging.tqdm(
                        pool.imap(
                            self._batch_csv				,			[(offset, header, index, to_csv_kwargs) for offset in range(0				,			UpperCamelCase_				,			UpperCamelCase_					)]				,			)				,			total=(num_rows // batch_size) + 1 if num_rows % batch_size else num_rows // batch_size				,			unit="ba"				,			disable=not logging.is_progress_bar_enabled()				,			desc="Creating CSV from Arrow format"				,			):
                          written += file_obj.write(UpperCamelCase_					)

        return written








"""simple docstring"""






from math import radians as angle_to_radians
from math import sin

# Acceleration Constant on Earth (unit m/s^2)
A_			  =    9.80665




def 						_UpperCamelCase			(  A    ,       A			):

   # Ensure valid instance
   if not isinstance(A    ,       (int, float)			):
      raise TypeError("Invalid velocity. Should be a positive number."			)

   if not isinstance(A    ,       (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 						_UpperCamelCase			(  A    ,       A			):
   check_args(A    ,       A			)
   UpperCamelCase_     =angle_to_radians(2 * angle			)
   return round(init_velocity**2 * sin(A			) / g    ,       2			)




def 						_UpperCamelCase			(  A    ,       A			):
   check_args(A    ,       A			)
   UpperCamelCase_     =angle_to_radians(A			)
   return round(init_velocity**2 * sin(A			) ** 2 / (2 * g)    ,       2			)




def 						_UpperCamelCase			(  A    ,       A			):
   check_args(A    ,       A			)
   UpperCamelCase_     =angle_to_radians(A			)
   return round(2 * init_velocity * sin(A			) / g    ,       2			)




def 						_UpperCamelCase			(  ):
   UpperCamelCase_    ,							UpperCamelCase_     =25, 20
   assert horizontal_distance(A    ,       A			) == 40.97
   assert max_height(A    ,       A			) == 3.73
   assert total_time(A    ,       A			) == 1.74


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

    testmod()

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

    # Get input from user
    A_			  =    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]''')
