



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__  :  Tuple       = {
    '''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(  __UpperCamelCase							:		int			):
		lowerCAmelCase_      :					Any     =			task_cls()
		lowerCAmelCase_      :					Optional[Any]     =			asdict(__UpperCamelCase			)
		lowerCAmelCase_      :					Union[str, Any]     =			task_template_from_dict(__UpperCamelCase			)
		assert task == reloaded



class     __snake_case						:






							"""simple docstring"""




							def        UpperCAmelCase__      (	self					:	Optional[Any]):
									lowerCAmelCase_      :					Dict     =			LanguageModeling(text_column='''input_text''')
									assert {"input_text": "text"} == task.column_mapping







							def        UpperCAmelCase__      (	self					:	List[str]):
									lowerCAmelCase_      :					List[Any]     =			Features({'''text''': Value('''string''')})
									lowerCAmelCase_      :					Optional[Any]     =			{'''text_column''': '''input_text'''}
									lowerCAmelCase_      :					str     =			LanguageModeling.from_dict(A_)
									assert "language-modeling" == task.task
									assert input_schema == task.input_schema





class     __snake_case						(					UpperCamelCase_						):






							"""simple docstring"""




							def        UpperCAmelCase__      (	self					:	Union[str, Any]):
									lowerCAmelCase_      :					Optional[Any]     =			sorted(['''pos''', '''neg'''])




							def        UpperCAmelCase__      (	self					:	List[str]):
									lowerCAmelCase_      :					List[Any]     =			TextClassification(text_column='''input_text'''    ,    label_column='''input_label''')
									self.assertDictEqual({'''input_text''': '''text''', '''input_label''': '''labels'''}    ,    task.column_mapping)




							def        UpperCAmelCase__      (	self					:	Union[str, Any]):
									lowerCAmelCase_      :					Dict     =			Features({'''text''': Value('''string''')})
									# Labels are cast to tuple during `TextClassification.__post_init__`, so we do the same here
									lowerCAmelCase_      :					Union[str, Any]     =			Features({'''labels''': ClassLabel})
									lowerCAmelCase_      :					Optional[int]     =			{'''text_column''': '''input_text''', '''label_column''': '''input_labels'''}
									lowerCAmelCase_      :					Tuple     =			TextClassification.from_dict(A_)
									self.assertEqual('''text-classification'''    ,    task.task)
									self.assertEqual(A_    ,    task.input_schema)
									self.assertEqual(A_    ,    task.label_schema)







							def        UpperCAmelCase__      (	self					:	int):
									lowerCAmelCase_      :					Any     =			TextClassification(text_column='''input_text'''    ,    label_column='''input_label''')
									self.assertEqual(task.label_schema['''labels''']    ,    A_)
									lowerCAmelCase_      :					str     =			task.align_with_features(Features({'''input_label''': ClassLabel(names=self.labels)}))
									self.assertEqual(task.label_schema['''labels''']    ,    ClassLabel(names=self.labels))





class     __snake_case						(					UpperCamelCase_						):






							"""simple docstring"""




							def        UpperCAmelCase__      (	self					:	Union[str, Any]):
									lowerCAmelCase_      :					Any     =			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					:	int):
									lowerCAmelCase_      :					Optional[int]     =			Features({'''question''': Value('''string'''), '''context''': Value('''string''')})
									lowerCAmelCase_      :					Tuple     =			Features(
									    {
									        '''answers''': Sequence(
									            {
									                '''text''': Value('''string'''),
									                '''answer_start''': Value('''int32'''),
									            })
									    })
									lowerCAmelCase_      :					Dict     =			{
									    '''context_column''': '''input_input_context''',
									    '''question_column''': '''input_question''',
									    '''answers_column''': '''input_answers''',
									}
									lowerCAmelCase_      :					Dict     =			QuestionAnsweringExtractive.from_dict(A_)
									self.assertEqual('''question-answering-extractive'''    ,    task.task)
									self.assertEqual(A_    ,    task.input_schema)
									self.assertEqual(A_    ,    task.label_schema)





class     __snake_case						(					UpperCamelCase_						):






							"""simple docstring"""




							def        UpperCAmelCase__      (	self					:	Optional[int]):
									lowerCAmelCase_      :					str     =			Summarization(text_column='''input_text'''    ,    summary_column='''input_summary''')
									self.assertDictEqual({'''input_text''': '''text''', '''input_summary''': '''summary'''}    ,    task.column_mapping)







							def        UpperCAmelCase__      (	self					:	Any):
									lowerCAmelCase_      :					Any     =			Features({'''text''': Value('''string''')})
									lowerCAmelCase_      :					Optional[Any]     =			Features({'''summary''': Value('''string''')})
									lowerCAmelCase_      :					Dict     =			{'''text_column''': '''input_text''', '''summary_column''': '''input_summary'''}
									lowerCAmelCase_      :					Union[str, Any]     =			Summarization.from_dict(A_)
									self.assertEqual('''summarization'''    ,    task.task)
									self.assertEqual(A_    ,    task.input_schema)
									self.assertEqual(A_    ,    task.label_schema)





class     __snake_case						(					UpperCamelCase_						):






							"""simple docstring"""




							def        UpperCAmelCase__      (	self					:	Optional[Any]):
									lowerCAmelCase_      :					str     =			AutomaticSpeechRecognition(audio_column='''input_audio'''    ,    transcription_column='''input_transcription''')
									self.assertDictEqual({'''input_audio''': '''audio''', '''input_transcription''': '''transcription'''}    ,    task.column_mapping)







							def        UpperCAmelCase__      (	self					:	Dict):
									lowerCAmelCase_      :					Optional[Any]     =			Features({'''audio''': Audio()})
									lowerCAmelCase_      :					Tuple     =			Features({'''transcription''': Value('''string''')})
									lowerCAmelCase_      :					Optional[int]     =			{
									    '''audio_column''': '''input_audio''',
									    '''transcription_column''': '''input_transcription''',
									}
									lowerCAmelCase_      :					Optional[Any]     =			AutomaticSpeechRecognition.from_dict(A_)
									self.assertEqual('''automatic-speech-recognition'''    ,    task.task)
									self.assertEqual(A_    ,    task.input_schema)
									self.assertEqual(A_    ,    task.label_schema)





class     __snake_case						(					UpperCamelCase_						):






							"""simple docstring"""




							def        UpperCAmelCase__      (	self					:	List[str]):
									lowerCAmelCase_      :					int     =			sorted(['''pos''', '''neg'''])




							def        UpperCAmelCase__      (	self					:	int):
									lowerCAmelCase_      :					List[Any]     =			AudioClassification(audio_column='''input_audio'''    ,    label_column='''input_label''')
									self.assertDictEqual({'''input_audio''': '''audio''', '''input_label''': '''labels'''}    ,    task.column_mapping)




							def        UpperCAmelCase__      (	self					:	Optional[Any]):
									lowerCAmelCase_      :					Dict     =			Features({'''audio''': Audio()})
									lowerCAmelCase_      :					Dict     =			Features({'''labels''': ClassLabel})
									lowerCAmelCase_      :					Union[str, Any]     =			{
									    '''audio_column''': '''input_image''',
									    '''label_column''': '''input_label''',
									}
									lowerCAmelCase_      :					List[Any]     =			AudioClassification.from_dict(A_)
									self.assertEqual('''audio-classification'''    ,    task.task)
									self.assertEqual(A_    ,    task.input_schema)
									self.assertEqual(A_    ,    task.label_schema)







							def        UpperCAmelCase__      (	self					:	Dict):
									lowerCAmelCase_      :					int     =			AudioClassification(audio_column='''input_audio'''    ,    label_column='''input_label''')
									self.assertEqual(task.label_schema['''labels''']    ,    A_)
									lowerCAmelCase_      :					Optional[Any]     =			task.align_with_features(Features({'''input_label''': ClassLabel(names=self.labels)}))
									self.assertEqual(task.label_schema['''labels''']    ,    ClassLabel(names=self.labels))





class     __snake_case						(					UpperCamelCase_						):






							"""simple docstring"""




							def        UpperCAmelCase__      (	self					:	Tuple):
									lowerCAmelCase_      :					Optional[int]     =			sorted(['''pos''', '''neg'''])




							def        UpperCAmelCase__      (	self					:	Optional[Any]):
									lowerCAmelCase_      :					int     =			ImageClassification(image_column='''input_image'''    ,    label_column='''input_label''')
									self.assertDictEqual({'''input_image''': '''image''', '''input_label''': '''labels'''}    ,    task.column_mapping)




							def        UpperCAmelCase__      (	self					:	int):
									lowerCAmelCase_      :					Tuple     =			Features({'''image''': Image()})
									lowerCAmelCase_      :					str     =			Features({'''labels''': ClassLabel})
									lowerCAmelCase_      :					str     =			{
									    '''image_column''': '''input_image''',
									    '''label_column''': '''input_label''',
									}
									lowerCAmelCase_      :					Any     =			ImageClassification.from_dict(A_)
									self.assertEqual('''image-classification'''    ,    task.task)
									self.assertEqual(A_    ,    task.input_schema)
									self.assertEqual(A_    ,    task.label_schema)







							def        UpperCAmelCase__      (	self					:	Any):
									lowerCAmelCase_      :					Dict     =			ImageClassification(image_column='''input_image'''    ,    label_column='''input_label''')
									self.assertEqual(task.label_schema['''labels''']    ,    A_)
									lowerCAmelCase_      :					int     =			task.align_with_features(Features({'''input_label''': ClassLabel(names=self.labels)}))
									self.assertEqual(task.label_schema['''labels''']    ,    ClassLabel(names=self.labels))





class     __snake_case						(					UpperCamelCase_						):






							"""simple docstring"""




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

									def keep_task(A_					:	Optional[int]):
											return x

									def dont_keep_task(A_					:	Tuple):
											lowerCAmelCase_      :					Optional[int]     =			deepcopy(A_)
											lowerCAmelCase_      :					Tuple     =			0
											return out

									lowerCAmelCase_      :					List[str]     =			dataset.map(A_)
									assert mapped_dataset.info.task_templates == dataset.info.task_templates
									# reload from cache
									lowerCAmelCase_      :					Any     =			dataset.map(A_)
									assert mapped_dataset.info.task_templates == dataset.info.task_templates

									lowerCAmelCase_      :					Tuple     =			dataset.map(A_)
									assert mapped_dataset.info.task_templates == []
									# reload from cache
									lowerCAmelCase_      :					List[str]     =			dataset.map(A_)
									assert mapped_dataset.info.task_templates == []







							def        UpperCAmelCase__      (	self					:	Dict):
									lowerCAmelCase_      :					Union[str, Any]     =			Features({'''text''': Value('''string'''), '''label''': ClassLabel(names=('''pos''', '''neg'''))})
									lowerCAmelCase_      :					Optional[Any]     =			TextClassification(text_column='''text'''    ,    label_column='''label''')
									lowerCAmelCase_      :					Tuple     =			DatasetInfo(features=A_    ,    task_templates=A_)
									lowerCAmelCase_      :					List[Any]     =			Dataset.from_dict({'''text''': ['''A sentence.'''], '''label''': ['''pos''']}    ,    info=A_)

									def process(A_					:	Any):
											return example

									lowerCAmelCase_      :					List[Any]     =			dataset.remove_columns('''label''')
									lowerCAmelCase_      :					Optional[Any]     =			modified_dataset.map(A_)
									assert mapped_dataset.info.task_templates == []










from math import radians as angle_to_radians
from math import sin

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


def       UpperCamelCase(  __UpperCamelCase							:		float					,__UpperCamelCase							:		float			):

		# Ensure valid instance
		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							:		float					,__UpperCamelCase							:		float			):
		check_args(__UpperCamelCase					,__UpperCamelCase			)
		lowerCAmelCase_      :					Optional[Any]     =			angle_to_radians(2 * angle			)
		return round(init_velocity**2 * sin(__UpperCamelCase			) / g					,2			)


def       UpperCamelCase(  __UpperCamelCase							:		float					,__UpperCamelCase							:		float			):
		check_args(__UpperCamelCase					,__UpperCamelCase			)
		lowerCAmelCase_      :					Any     =			angle_to_radians(__UpperCamelCase			)
		return round(init_velocity**2 * sin(__UpperCamelCase			) ** 2 / (2 * g)					,2			)


def       UpperCamelCase(  __UpperCamelCase							:		float					,__UpperCamelCase							:		float			):
		check_args(__UpperCamelCase					,__UpperCamelCase			)
		lowerCAmelCase_      :					Dict     =			angle_to_radians(__UpperCamelCase			)
		return round(2 * init_velocity * sin(__UpperCamelCase			) / g					,2			)


def       UpperCamelCase(  ):
		lowerCAmelCase_ ,  lowerCAmelCase_      :					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
						A__  :  List[Any]       = float(input('''Initial Velocity: ''').strip())

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





