

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  UpperCamelCase_      (	unittest.TestCase		,  _snake_case      ):


  """simple docstring"""



  def   _UpperCamelCase     (						self     :					Union[str, Any]						)       ->			Tuple:
      SCREAMING_SNAKE_CASE__         =    load_tool("image-captioning"						)
      self.tool.setup()
      SCREAMING_SNAKE_CASE__         =    load_tool("image-captioning"  ,	remote=A_						)



  def   _UpperCamelCase     (						self     :					Union[str, Any]						)       ->			List[str]:
      SCREAMING_SNAKE_CASE__         =    Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"						)						) / "000000039769.png"						)
      SCREAMING_SNAKE_CASE__         =    self.tool(A_						)
      self.assertEqual(A_  ,	"two cats sleeping on a couch"						)



  def   _UpperCamelCase     (						self     :					Optional[Any]						)       ->			Tuple:
      SCREAMING_SNAKE_CASE__         =    Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"						)						) / "000000039769.png"						)
      SCREAMING_SNAKE_CASE__         =    self.remote_tool(A_						)
      self.assertEqual(A_  ,	"two cats sleeping on a couch"						)



  def   _UpperCamelCase     (						self     :					Tuple						)       ->			Dict:
      SCREAMING_SNAKE_CASE__         =    Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"						)						) / "000000039769.png"						)
      SCREAMING_SNAKE_CASE__         =    self.tool(image=A_						)
      self.assertEqual(A_  ,	"two cats sleeping on a couch"						)







  def   _UpperCamelCase     (						self     :					Dict						)       ->			int:
      SCREAMING_SNAKE_CASE__         =    Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"						)						) / "000000039769.png"						)
      SCREAMING_SNAKE_CASE__         =    self.remote_tool(image=A_						)
      self.assertEqual(A_  ,	"two cats sleeping on a couch"						)










from math import radians as angle_to_radians
from math import sin

# Acceleration Constant on Earth (unit m/s^2)
__lowerCamelCase						= 9.8_06_65






def    UpperCamelCase__  (   UpperCAmelCase    ,	UpperCAmelCase     )     ->		None:







							"""simple docstring"""





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

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







							"""simple docstring"""





							check_args(UpperCAmelCase    ,	UpperCAmelCase     )
							_a  :    Dict			=						angle_to_radians(2 * angle     )
							return round(init_velocity**2 * sin(UpperCAmelCase     ) / g    ,	2     )






def    UpperCamelCase__  (   UpperCAmelCase    ,	UpperCAmelCase     )     ->		float:







							"""simple docstring"""





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






def    UpperCamelCase__  (   UpperCAmelCase    ,	UpperCAmelCase     )     ->		float:







							"""simple docstring"""





							check_args(UpperCAmelCase    ,	UpperCAmelCase     )
							_a  :    str			=						angle_to_radians(UpperCAmelCase     )
							return round(2 * init_velocity * sin(UpperCAmelCase     ) / g    ,	2     )






def    UpperCamelCase__  (   )     ->		None:







							"""simple docstring"""





							_a		,					_a  :    Any			=						25, 20
							assert horizontal_distance(UpperCAmelCase    ,	UpperCAmelCase     ) == 4_0.9_7
							assert max_height(UpperCAmelCase    ,	UpperCAmelCase     ) == 3.7_3
							assert total_time(UpperCAmelCase    ,	UpperCAmelCase     ) == 1.7_4


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

						testmod()

						# Get input from user
						__lowerCamelCase						= float(input('Initial Velocity: ').strip())

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