





'''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_0_6_6_5





def lowerCamelCase						(					__lowerCamelCase			:   float ,	__lowerCamelCase			:   float   )						->None:

    # Ensure valid instance
    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 lowerCamelCase						(					__lowerCamelCase			:   float ,	__lowerCamelCase			:   float   )						->float:
    check_args(__lowerCamelCase ,	__lowerCamelCase   )
    _SCREAMING_SNAKE_CASE     =      angle_to_radians(2 * angle   )
    return round(init_velocity**2 * sin(__lowerCamelCase   ) / g ,	2   )





def lowerCamelCase						(					__lowerCamelCase			:   float ,	__lowerCamelCase			:   float   )						->float:
    check_args(__lowerCamelCase ,	__lowerCamelCase   )
    _SCREAMING_SNAKE_CASE     =      angle_to_radians(__lowerCamelCase   )
    return round(init_velocity**2 * sin(__lowerCamelCase   ) ** 2 / (2 * g) ,	2   )





def lowerCamelCase						(					__lowerCamelCase			:   float ,	__lowerCamelCase			:   float   )						->float:
    check_args(__lowerCamelCase ,	__lowerCamelCase   )
    _SCREAMING_SNAKE_CASE     =      angle_to_radians(__lowerCamelCase   )
    return round(2 * init_velocity * sin(__lowerCamelCase   ) / g ,	2   )





def lowerCamelCase						(					)						->None:
    _SCREAMING_SNAKE_CASE    ,	_SCREAMING_SNAKE_CASE     =      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
      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]""")










'''simple docstring'''

import torch

from diffusers import LMSDiscreteScheduler
from diffusers.utils import torch_device

from .test_schedulers import SchedulerCommonTest


class  a_					(    snake_case_	):

    '''simple docstring'''
    UpperCamelCase			   =			(LMSDiscreteScheduler,)
    UpperCamelCase			   =			10


    def       snake_case_(		self			,		**A	)		->       str:
        _SCREAMING_SNAKE_CASE     =      {
            """num_train_timesteps""": 1100,
            """beta_start""": 0.0001,
            """beta_end""": 0.02,
            """beta_schedule""": """linear""",
        }

        config.update(**A	)
        return config


    def       snake_case_(		self	)		->       str:
        for timesteps in [10, 50, 100, 1000]:
            self.check_over_configs(num_train_timesteps=A	)


    def       snake_case_(		self	)		->       Optional[Any]:
        for beta_start, beta_end in zip([0.0_0001, 0.0001, 0.001]			,		[0.0002, 0.002, 0.02]	):
            self.check_over_configs(beta_start=A			,		beta_end=A	)


    def       snake_case_(		self	)		->       Tuple:
        for schedule in ["linear", "scaled_linear"]:
            self.check_over_configs(beta_schedule=A	)


    def       snake_case_(		self	)		->       List[str]:
        for prediction_type in ["epsilon", "v_prediction"]:
            self.check_over_configs(prediction_type=A	)


    def       snake_case_(		self	)		->       Optional[int]:
        for t in [0, 500, 800]:
            self.check_over_forward(time_step=A	)


    def       snake_case_(		self	)		->       str:
        _SCREAMING_SNAKE_CASE     =      self.scheduler_classes[0]
        _SCREAMING_SNAKE_CASE     =      self.get_scheduler_config()
        _SCREAMING_SNAKE_CASE     =      scheduler_class(**A	)

        scheduler.set_timesteps(self.num_inference_steps	)

        _SCREAMING_SNAKE_CASE     =      self.dummy_model()
        _SCREAMING_SNAKE_CASE     =      self.dummy_sample_deter * scheduler.init_noise_sigma

        for i, t in enumerate(scheduler.timesteps	):
            _SCREAMING_SNAKE_CASE     =      scheduler.scale_model_input(A			,		A	)

            _SCREAMING_SNAKE_CASE     =      model(A			,		A	)

            _SCREAMING_SNAKE_CASE     =      scheduler.step(A			,		A			,		A	)
            _SCREAMING_SNAKE_CASE     =      output.prev_sample

        _SCREAMING_SNAKE_CASE     =      torch.sum(torch.abs(A	)	)
        _SCREAMING_SNAKE_CASE     =      torch.mean(torch.abs(A	)	)

        assert abs(result_sum.item() - 1006.388	) < 1e-2
        assert abs(result_mean.item() - 1.31	) < 1e-3


    def       snake_case_(		self	)		->       Tuple:
        _SCREAMING_SNAKE_CASE     =      self.scheduler_classes[0]
        _SCREAMING_SNAKE_CASE     =      self.get_scheduler_config(prediction_type="""v_prediction"""	)
        _SCREAMING_SNAKE_CASE     =      scheduler_class(**A	)

        scheduler.set_timesteps(self.num_inference_steps	)

        _SCREAMING_SNAKE_CASE     =      self.dummy_model()
        _SCREAMING_SNAKE_CASE     =      self.dummy_sample_deter * scheduler.init_noise_sigma

        for i, t in enumerate(scheduler.timesteps	):
            _SCREAMING_SNAKE_CASE     =      scheduler.scale_model_input(A			,		A	)

            _SCREAMING_SNAKE_CASE     =      model(A			,		A	)

            _SCREAMING_SNAKE_CASE     =      scheduler.step(A			,		A			,		A	)
            _SCREAMING_SNAKE_CASE     =      output.prev_sample

        _SCREAMING_SNAKE_CASE     =      torch.sum(torch.abs(A	)	)
        _SCREAMING_SNAKE_CASE     =      torch.mean(torch.abs(A	)	)

        assert abs(result_sum.item() - 0.0017	) < 1e-2
        assert abs(result_mean.item() - 2.26_76e-06	) < 1e-3


    def       snake_case_(		self	)		->       Tuple:
        _SCREAMING_SNAKE_CASE     =      self.scheduler_classes[0]
        _SCREAMING_SNAKE_CASE     =      self.get_scheduler_config()
        _SCREAMING_SNAKE_CASE     =      scheduler_class(**A	)

        scheduler.set_timesteps(self.num_inference_steps			,		device=A	)

        _SCREAMING_SNAKE_CASE     =      self.dummy_model()
        _SCREAMING_SNAKE_CASE     =      self.dummy_sample_deter * scheduler.init_noise_sigma.cpu()
        _SCREAMING_SNAKE_CASE     =      sample.to(A	)

        for i, t in enumerate(scheduler.timesteps	):
            _SCREAMING_SNAKE_CASE     =      scheduler.scale_model_input(A			,		A	)

            _SCREAMING_SNAKE_CASE     =      model(A			,		A	)

            _SCREAMING_SNAKE_CASE     =      scheduler.step(A			,		A			,		A	)
            _SCREAMING_SNAKE_CASE     =      output.prev_sample

        _SCREAMING_SNAKE_CASE     =      torch.sum(torch.abs(A	)	)
        _SCREAMING_SNAKE_CASE     =      torch.mean(torch.abs(A	)	)

        assert abs(result_sum.item() - 1006.388	) < 1e-2
        assert abs(result_mean.item() - 1.31	) < 1e-3





    def       snake_case_(		self	)		->       Tuple:
        _SCREAMING_SNAKE_CASE     =      self.scheduler_classes[0]
        _SCREAMING_SNAKE_CASE     =      self.get_scheduler_config()
        _SCREAMING_SNAKE_CASE     =      scheduler_class(**A			,		use_karras_sigmas=A	)

        scheduler.set_timesteps(self.num_inference_steps			,		device=A	)

        _SCREAMING_SNAKE_CASE     =      self.dummy_model()
        _SCREAMING_SNAKE_CASE     =      self.dummy_sample_deter.to(A	) * scheduler.init_noise_sigma
        _SCREAMING_SNAKE_CASE     =      sample.to(A	)

        for t in scheduler.timesteps:
            _SCREAMING_SNAKE_CASE     =      scheduler.scale_model_input(A			,		A	)

            _SCREAMING_SNAKE_CASE     =      model(A			,		A	)

            _SCREAMING_SNAKE_CASE     =      scheduler.step(A			,		A			,		A	)
            _SCREAMING_SNAKE_CASE     =      output.prev_sample

        _SCREAMING_SNAKE_CASE     =      torch.sum(torch.abs(A	)	)
        _SCREAMING_SNAKE_CASE     =      torch.mean(torch.abs(A	)	)

        assert abs(result_sum.item() - 3812.9927	) < 2e-2
        assert abs(result_mean.item() - 4.9648	) < 1e-3



