



"""simple docstring"""
import itertools
from dataclasses import dataclass
from typing import Optional

import pyarrow as pa

import datasets
from datasets.table import table_cast


__a     =    datasets.utils.logging.get_logger(__name__)
@dataclass
class     lowerCamelCase  (      datasets.BuilderConfig    ):






					'''simple docstring'''





					_A		:      Optional[datasets.Features]						=					None

class     lowerCamelCase  (      datasets.ArrowBasedBuilder    ):






					'''simple docstring'''





					_A		:      Optional[Any]						=					ArrowConfig






					def        lowerCAmelCase_    (	self:							int						)       ->     List[Any]:
											return datasets.DatasetInfo(features=self.config.features						)






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






					def        lowerCAmelCase_    (	self:							Union[str, Any]						,					snake_case:							pa.Table						)       ->     pa.Table:
											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
																	snake_case_			:Tuple						=      table_cast(snake_case						,					self.info.features.arrow_schema						)
											return pa_table






					def        lowerCAmelCase_    (	self:							Optional[int]						,					snake_case:							Union[str, Any]						)       ->     List[Any]:
											for file_idx, file in enumerate(itertools.chain.from_iterable(snake_case						)						):
																	with open(snake_case						,					"""rb"""						) as f:
																							try:
																													for batch_idx, record_batch in enumerate(pa.ipc.open_stream(snake_case						)						):
																																			snake_case_			:Union[str, Any]						=      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(snake_case						)
																							except ValueError as e:
																													logger.error(f"""Failed to read file '{file}' with error {type(snake_case						)}: {e}"""						)
																													raise





"""simple docstring"""
from math import radians as angle_to_radians
from math import sin

# Acceleration Constant on Earth (unit m/s^2)
__a     =    9.8_06_65
def        A_  (      _lowercase, _lowercase     ):







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







						'''simple docstring'''


						check_args(_lowercase, _lowercase     )
						snake_case_			:str						=      angle_to_radians(2 * angle     )
						return round(init_velocity**2 * sin(_lowercase     ) / g, 2     )
def        A_  (      _lowercase, _lowercase     ):







						'''simple docstring'''


						check_args(_lowercase, _lowercase     )
						snake_case_			:str						=      angle_to_radians(_lowercase     )
						return round(init_velocity**2 * sin(_lowercase     ) ** 2 / (2 * g), 2     )
def        A_  (      _lowercase, _lowercase     ):







						'''simple docstring'''


						check_args(_lowercase, _lowercase     )
						snake_case_			:Optional[int]						=      angle_to_radians(_lowercase     )
						return round(2 * init_velocity * sin(_lowercase     ) / g, 2     )
def        A_  (      ):







						'''simple docstring'''


						snake_case_,	snake_case_			:List[str]						=      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
						__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]""")
