



import unittest
from pathlib import Path

from transformers import is_vision_available, load_tool
from transformers.testing_utils import get_tests_dir

from .test_tools_common import ToolTesterMixin


if is_vision_available():
	from PIL import Image






class 	lowercase		(				unittest.TestCase				,					snake_case__):






	"""simple docstring"""


	def 						_SCREAMING_SNAKE_CASE	(			self			:		Dict  )    ->				Any:
							UpperCAmelCase_=     load_tool("""image-segmentation"""  )
							self.tool.setup()
							UpperCAmelCase_=     load_tool("""image-segmentation"""		,						remote=__UpperCAmelCase  )




	def 						_SCREAMING_SNAKE_CASE	(			self			:		List[Any]  )    ->				List[Any]:
							UpperCAmelCase_=     Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""  )  ) / """000000039769.png"""  )
							UpperCAmelCase_=     self.tool(__UpperCAmelCase		,						"""cat"""  )
							self.assertTrue(isinstance(__UpperCAmelCase		,						Image.Image  )  )




	def 						_SCREAMING_SNAKE_CASE	(			self			:		List[Any]  )    ->				Optional[int]:
							UpperCAmelCase_=     Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""  )  ) / """000000039769.png"""  )
							UpperCAmelCase_=     self.remote_tool(__UpperCAmelCase		,						"""cat"""  )
							self.assertTrue(isinstance(__UpperCAmelCase		,						Image.Image  )  )




	def 						_SCREAMING_SNAKE_CASE	(			self			:		List[Any]  )    ->				Optional[int]:
							UpperCAmelCase_=     Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""  )  ) / """000000039769.png"""  )
							UpperCAmelCase_=     self.tool(image=__UpperCAmelCase		,						label="""cat"""  )
							self.assertTrue(isinstance(__UpperCAmelCase		,						Image.Image  )  )




	def 						_SCREAMING_SNAKE_CASE	(			self			:		Any  )    ->				int:
							UpperCAmelCase_=     Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""  )  ) / """000000039769.png"""  )
							UpperCAmelCase_=     self.remote_tool(image=__UpperCAmelCase		,						label="""cat"""  )
							self.assertTrue(isinstance(__UpperCAmelCase		,						Image.Image  )  )









from math import radians as angle_to_radians
from math import sin

# Acceleration Constant on Earth (unit m/s^2)
__A       					=		9.8_0_6_6_5



def  __a  (					lowerCAmelCase_     :      float    ,lowerCAmelCase_     :      float       )   ->				None:






						'''simple docstring'''



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

						if not isinstance(lowerCAmelCase_    ,(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  (					lowerCAmelCase_     :      float    ,lowerCAmelCase_     :      float       )   ->				float:






						'''simple docstring'''



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



def  __a  (					lowerCAmelCase_     :      float    ,lowerCAmelCase_     :      float       )   ->				float:






						'''simple docstring'''



						check_args(lowerCAmelCase_    ,lowerCAmelCase_       )
						UpperCAmelCase_=     angle_to_radians(lowerCAmelCase_       )
						return round(init_velocity**2 * sin(lowerCAmelCase_       ) ** 2 / (2 * g)    ,2       )



def  __a  (					lowerCAmelCase_     :      float    ,lowerCAmelCase_     :      float       )   ->				float:






						'''simple docstring'''



						check_args(lowerCAmelCase_    ,lowerCAmelCase_       )
						UpperCAmelCase_=     angle_to_radians(lowerCAmelCase_       )
						return round(2 * init_velocity * sin(lowerCAmelCase_       ) / g    ,2       )



def  __a  (					)   ->				None:






						'''simple docstring'''



						UpperCAmelCase_,     UpperCAmelCase_=     25, 20
						assert horizontal_distance(lowerCAmelCase_    ,lowerCAmelCase_       ) == 40.97
						assert max_height(lowerCAmelCase_    ,lowerCAmelCase_       ) == 3.73
						assert total_time(lowerCAmelCase_    ,lowerCAmelCase_       ) == 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]')




