






"""simple docstring"""






from copy import deepcopy
from unittest.case import TestCase

import pytest

from datasets.arrow_dataset import Dataset
from datasets.features import Audio, ClassLabel, Features, Image, Sequence, Value
from datasets.info import DatasetInfo
from datasets.tasks import (
    AudioClassification,
    AutomaticSpeechRecognition,
    ImageClassification,
    LanguageModeling,
    QuestionAnsweringExtractive,
    Summarization,
    TextClassification,
    task_template_from_dict,
)
from datasets.utils.py_utils import asdict


A_			  =    {
    "id": "5733be284776f41900661182",
    "title": "University_of_Notre_Dame",
    "context": "Architecturally, the school has a Catholic character. Atop the Main Building\'s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend \"Venite Ad Me Omnes\". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary.",
    "question": "To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?",
    "answers": {"text": ["Saint Bernadette Soubirous"], "answer_start": [515]},
}




@pytest.mark.parametrize(
    "task_cls"    ,       [
        AudioClassification,
        AutomaticSpeechRecognition,
        ImageClassification,
        LanguageModeling,
        QuestionAnsweringExtractive,
        Summarization,
        TextClassification,
    ]    ,       )
def 						_UpperCamelCase			(  A			):
   UpperCamelCase_     =task_cls()
   UpperCamelCase_     =asdict(A			)
   UpperCamelCase_     =task_template_from_dict(A			)
   assert task == reloaded
class 						__lowerCAmelCase   :







  '''simple docstring'''


  def 					UpperCamelCase__   (      self:		Optional[int]					):
     UpperCamelCase_     =LanguageModeling(text_column="input_text"					)
     assert {"input_text": "text"} == task.column_mapping





  def 					UpperCamelCase__   (      self:		Dict					):
     UpperCamelCase_     =Features({"text": Value("string"					)}					)
     UpperCamelCase_     ={"text_column": "input_text"}
     UpperCamelCase_     =LanguageModeling.from_dict(UpperCamelCase_					)
     assert "language-modeling" == task.task
     assert input_schema == task.input_schema




class 						__lowerCAmelCase   (			UpperCAmelCase       ):







  '''simple docstring'''


  def 					UpperCamelCase__   (      self:		List[str]					):
     UpperCamelCase_     =sorted(["pos", "neg"]					)
  def 					UpperCamelCase__   (      self:		Optional[Any]					):
     UpperCamelCase_     =TextClassification(text_column="input_text"				,			label_column="input_label"					)
     self.assertDictEqual({"input_text": "text", "input_label": "labels"}				,			task.column_mapping					)
  def 					UpperCamelCase__   (      self:		List[str]					):
     UpperCamelCase_     =Features({"text": Value("string"					)}					)
     # Labels are cast to tuple during `TextClassification.__post_init__`, so we do the same here
     UpperCamelCase_     =Features({"labels": ClassLabel}					)
     UpperCamelCase_     ={"text_column": "input_text", "label_column": "input_labels"}
     UpperCamelCase_     =TextClassification.from_dict(UpperCamelCase_					)
     self.assertEqual("text-classification"				,			task.task					)
     self.assertEqual(UpperCamelCase_				,			task.input_schema					)
     self.assertEqual(UpperCamelCase_				,			task.label_schema					)





  def 					UpperCamelCase__   (      self:		List[Any]					):
     UpperCamelCase_     =TextClassification(text_column="input_text"				,			label_column="input_label"					)
     self.assertEqual(task.label_schema["labels"]				,			UpperCamelCase_					)
     UpperCamelCase_     =task.align_with_features(Features({"input_label": ClassLabel(names=self.labels					)}					)					)
     self.assertEqual(task.label_schema["labels"]				,			ClassLabel(names=self.labels					)					)




class 						__lowerCAmelCase   (			UpperCAmelCase       ):







  '''simple docstring'''


  def 					UpperCamelCase__   (      self:		List[str]					):
     UpperCamelCase_     =QuestionAnsweringExtractive(
         context_column="input_context"				,			question_column="input_question"				,			answers_column="input_answers"					)
     self.assertDictEqual(
         {"input_context": "context", "input_question": "question", "input_answers": "answers"}				,			task.column_mapping					)





  def 					UpperCamelCase__   (      self:		Any					):
     UpperCamelCase_     =Features({"question": Value("string"					), "context": Value("string"					)}					)
     UpperCamelCase_     =Features(
         {
             "answers": Sequence(
                 {
                     "text": Value("string"					),
                     "answer_start": Value("int32"					),
                 }					)
         }					)
     UpperCamelCase_     ={
         "context_column": "input_input_context",
         "question_column": "input_question",
         "answers_column": "input_answers",
     }
     UpperCamelCase_     =QuestionAnsweringExtractive.from_dict(UpperCamelCase_					)
     self.assertEqual("question-answering-extractive"				,			task.task					)
     self.assertEqual(UpperCamelCase_				,			task.input_schema					)
     self.assertEqual(UpperCamelCase_				,			task.label_schema					)




class 						__lowerCAmelCase   (			UpperCAmelCase       ):







  '''simple docstring'''


  def 					UpperCamelCase__   (      self:		Any					):
     UpperCamelCase_     =Summarization(text_column="input_text"				,			summary_column="input_summary"					)
     self.assertDictEqual({"input_text": "text", "input_summary": "summary"}				,			task.column_mapping					)





  def 					UpperCamelCase__   (      self:		Union[str, Any]					):
     UpperCamelCase_     =Features({"text": Value("string"					)}					)
     UpperCamelCase_     =Features({"summary": Value("string"					)}					)
     UpperCamelCase_     ={"text_column": "input_text", "summary_column": "input_summary"}
     UpperCamelCase_     =Summarization.from_dict(UpperCamelCase_					)
     self.assertEqual("summarization"				,			task.task					)
     self.assertEqual(UpperCamelCase_				,			task.input_schema					)
     self.assertEqual(UpperCamelCase_				,			task.label_schema					)




class 						__lowerCAmelCase   (			UpperCAmelCase       ):







  '''simple docstring'''


  def 					UpperCamelCase__   (      self:		Dict					):
     UpperCamelCase_     =AutomaticSpeechRecognition(audio_column="input_audio"				,			transcription_column="input_transcription"					)
     self.assertDictEqual({"input_audio": "audio", "input_transcription": "transcription"}				,			task.column_mapping					)





  def 					UpperCamelCase__   (      self:		Dict					):
     UpperCamelCase_     =Features({"audio": Audio()}					)
     UpperCamelCase_     =Features({"transcription": Value("string"					)}					)
     UpperCamelCase_     ={
         "audio_column": "input_audio",
         "transcription_column": "input_transcription",
     }
     UpperCamelCase_     =AutomaticSpeechRecognition.from_dict(UpperCamelCase_					)
     self.assertEqual("automatic-speech-recognition"				,			task.task					)
     self.assertEqual(UpperCamelCase_				,			task.input_schema					)
     self.assertEqual(UpperCamelCase_				,			task.label_schema					)




class 						__lowerCAmelCase   (			UpperCAmelCase       ):







  '''simple docstring'''


  def 					UpperCamelCase__   (      self:		Optional[Any]					):
     UpperCamelCase_     =sorted(["pos", "neg"]					)
  def 					UpperCamelCase__   (      self:		Union[str, Any]					):
     UpperCamelCase_     =AudioClassification(audio_column="input_audio"				,			label_column="input_label"					)
     self.assertDictEqual({"input_audio": "audio", "input_label": "labels"}				,			task.column_mapping					)
  def 					UpperCamelCase__   (      self:		Union[str, Any]					):
     UpperCamelCase_     =Features({"audio": Audio()}					)
     UpperCamelCase_     =Features({"labels": ClassLabel}					)
     UpperCamelCase_     ={
         "audio_column": "input_image",
         "label_column": "input_label",
     }
     UpperCamelCase_     =AudioClassification.from_dict(UpperCamelCase_					)
     self.assertEqual("audio-classification"				,			task.task					)
     self.assertEqual(UpperCamelCase_				,			task.input_schema					)
     self.assertEqual(UpperCamelCase_				,			task.label_schema					)





  def 					UpperCamelCase__   (      self:		str					):
     UpperCamelCase_     =AudioClassification(audio_column="input_audio"				,			label_column="input_label"					)
     self.assertEqual(task.label_schema["labels"]				,			UpperCamelCase_					)
     UpperCamelCase_     =task.align_with_features(Features({"input_label": ClassLabel(names=self.labels					)}					)					)
     self.assertEqual(task.label_schema["labels"]				,			ClassLabel(names=self.labels					)					)




class 						__lowerCAmelCase   (			UpperCAmelCase       ):







  '''simple docstring'''


  def 					UpperCamelCase__   (      self:		List[str]					):
     UpperCamelCase_     =sorted(["pos", "neg"]					)
  def 					UpperCamelCase__   (      self:		int					):
     UpperCamelCase_     =ImageClassification(image_column="input_image"				,			label_column="input_label"					)
     self.assertDictEqual({"input_image": "image", "input_label": "labels"}				,			task.column_mapping					)
  def 					UpperCamelCase__   (      self:		Any					):
     UpperCamelCase_     =Features({"image": Image()}					)
     UpperCamelCase_     =Features({"labels": ClassLabel}					)
     UpperCamelCase_     ={
         "image_column": "input_image",
         "label_column": "input_label",
     }
     UpperCamelCase_     =ImageClassification.from_dict(UpperCamelCase_					)
     self.assertEqual("image-classification"				,			task.task					)
     self.assertEqual(UpperCamelCase_				,			task.input_schema					)
     self.assertEqual(UpperCamelCase_				,			task.label_schema					)





  def 					UpperCamelCase__   (      self:		List[str]					):
     UpperCamelCase_     =ImageClassification(image_column="input_image"				,			label_column="input_label"					)
     self.assertEqual(task.label_schema["labels"]				,			UpperCamelCase_					)
     UpperCamelCase_     =task.align_with_features(Features({"input_label": ClassLabel(names=self.labels					)}					)					)
     self.assertEqual(task.label_schema["labels"]				,			ClassLabel(names=self.labels					)					)




class 						__lowerCAmelCase   (			UpperCAmelCase       ):







  '''simple docstring'''


  def 					UpperCamelCase__   (      self:		List[Any]					):
     UpperCamelCase_     =DatasetInfo(task_templates=QuestionAnsweringExtractive()					)
     UpperCamelCase_     =Dataset.from_dict({k: [v] for k, v in SAMPLE_QUESTION_ANSWERING_EXTRACTIVE.items()}				,			info=UpperCamelCase_					)
     assert isinstance(dataset.info.task_templates				,			UpperCamelCase_					)
     assert len(dataset.info.task_templates					) == 1

     def keep_task(UpperCamelCase_:		List[Any]					):
        return x

     def dont_keep_task(UpperCamelCase_:		Union[str, Any]					):
        UpperCamelCase_     =deepcopy(UpperCamelCase_					)
        UpperCamelCase_     =0
        return out

     UpperCamelCase_     =dataset.map(UpperCamelCase_					)
     assert mapped_dataset.info.task_templates == dataset.info.task_templates
     # reload from cache
     UpperCamelCase_     =dataset.map(UpperCamelCase_					)
     assert mapped_dataset.info.task_templates == dataset.info.task_templates

     UpperCamelCase_     =dataset.map(UpperCamelCase_					)
     assert mapped_dataset.info.task_templates == []
     # reload from cache
     UpperCamelCase_     =dataset.map(UpperCamelCase_					)
     assert mapped_dataset.info.task_templates == []





  def 					UpperCamelCase__   (      self:		Any					):
     UpperCamelCase_     =Features({"text": Value("string"					), "label": ClassLabel(names=("pos", "neg")					)}					)
     UpperCamelCase_     =TextClassification(text_column="text"				,			label_column="label"					)
     UpperCamelCase_     =DatasetInfo(features=UpperCamelCase_				,			task_templates=UpperCamelCase_					)
     UpperCamelCase_     =Dataset.from_dict({"text": ["A sentence."], "label": ["pos"]}				,			info=UpperCamelCase_					)

     def process(UpperCamelCase_:		Dict					):
        return example

     UpperCamelCase_     =dataset.remove_columns("label"					)
     UpperCamelCase_     =modified_dataset.map(UpperCamelCase_					)
     assert mapped_dataset.info.task_templates == []








"""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]''')
