

from math import atan, cos, radians, sin, tan

from .haversine_distance import haversine_distance

UpperCamelCase			    =     6_378_137.0
UpperCamelCase			    =     6_356_752.314_245
UpperCamelCase			    =     6_378_137

def 	__lowerCamelCase      (		snake_case__	,snake_case__	,snake_case__	,snake_case__		)							->  float:






						"""simple docstring"""





						_SCREAMING_SNAKE_CASE     				=  (AXIS_A - AXIS_B) / AXIS_A
						# Parametric latitudes
						# https://en.wikipedia.org/wiki/Latitude#Parametric_(or_reduced)_latitude
						_SCREAMING_SNAKE_CASE     				=  atan((1 - flattening) * tan(radians(snake_case__		)		)		)
						_SCREAMING_SNAKE_CASE     				=  atan((1 - flattening) * tan(radians(snake_case__		)		)		)

						# Compute central angle between two points
						# using haversine theta. sigma =  haversine_distance / equatorial radius
						_SCREAMING_SNAKE_CASE     				=  haversine_distance(snake_case__	,snake_case__	,snake_case__	,snake_case__		) / EQUATORIAL_RADIUS

						# Intermediate P and Q values
						_SCREAMING_SNAKE_CASE     				=  (b_lata + b_lata) / 2
						_SCREAMING_SNAKE_CASE     				=  (b_lata - b_lata) / 2

						# Intermediate X value
						# X = (sigma - sin(sigma)) * sin^2Pcos^2Q / cos^2(sigma/2)
						_SCREAMING_SNAKE_CASE     				=  (sin(snake_case__		) ** 2) * (cos(snake_case__		) ** 2)
						_SCREAMING_SNAKE_CASE     				=  cos(sigma / 2		) ** 2
						_SCREAMING_SNAKE_CASE     				=  (sigma - sin(snake_case__		)) * (x_numerator / x_demonimator)

						# Intermediate Y value
						# Y = (sigma + sin(sigma)) * cos^2Psin^2Q / sin^2(sigma/2)
						_SCREAMING_SNAKE_CASE     				=  (cos(snake_case__		) ** 2) * (sin(snake_case__		) ** 2)
						_SCREAMING_SNAKE_CASE     				=  sin(sigma / 2		) ** 2
						_SCREAMING_SNAKE_CASE     				=  (sigma + sin(snake_case__		)) * (y_numerator / y_denominator)

						return EQUATORIAL_RADIUS * (sigma - ((flattening / 2) * (x_value + y_value)))


if __name__ == "__main__":
		import doctest

		doctest.testmod()









import json
import os
import unittest

from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast
from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES
from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin



@require_tokenizers
class 				__UpperCAmelCase		(_UpperCAmelCase	,unittest.TestCase   ):
			__snake_case    :				Optional[Any]									=							OpenAIGPTTokenizer
			__snake_case    :				Dict									=							OpenAIGPTTokenizerFast
			__snake_case    :				Optional[Any]									=							True
			__snake_case    :				Dict									=							False







			def 							UpperCamelCase				(     self:  Union[str, Any]					):







									'''simple docstring'''




									super().setUp()

									# Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
									_SCREAMING_SNAKE_CASE     				=  [
									    """l""",
									    """o""",
									    """w""",
									    """e""",
									    """r""",
									    """s""",
									    """t""",
									    """i""",
									    """d""",
									    """n""",
									    """w</w>""",
									    """r</w>""",
									    """t</w>""",
									    """lo""",
									    """low""",
									    """er</w>""",
									    """low</w>""",
									    """lowest</w>""",
									    """newer</w>""",
									    """wider</w>""",
									    """<unk>""",
									]
									_SCREAMING_SNAKE_CASE     				=  dict(zip(UpperCAmelCase_				,     range(len(UpperCAmelCase_					)					)					)					)
									_SCREAMING_SNAKE_CASE     				=  ["""#version: 0.2""", """l o""", """lo w""", """e r</w>""", """"""]

									_SCREAMING_SNAKE_CASE     				=  os.path.join(self.tmpdirname				,     VOCAB_FILES_NAMES["""vocab_file"""]					)
									_SCREAMING_SNAKE_CASE     				=  os.path.join(self.tmpdirname				,     VOCAB_FILES_NAMES["""merges_file"""]					)
									with open(self.vocab_file				,     """w"""					) as fp:
															fp.write(json.dumps(UpperCAmelCase_					)					)
									with open(self.merges_file				,     """w"""					) as fp:
															fp.write("""\n""".join(UpperCAmelCase_					)					)







			def 							UpperCamelCase				(     self:  List[Any]				,     UpperCAmelCase_:  Dict					):







									'''simple docstring'''




									return "lower newer", "lower newer"







			def 							UpperCamelCase				(     self:  Any					):







									'''simple docstring'''




									_SCREAMING_SNAKE_CASE     				=  OpenAIGPTTokenizer(self.vocab_file				,     self.merges_file					)

									_SCREAMING_SNAKE_CASE     				=  """lower"""
									_SCREAMING_SNAKE_CASE     				=  ["""low""", """er</w>"""]
									_SCREAMING_SNAKE_CASE     				=  tokenizer.tokenize(UpperCAmelCase_					)
									self.assertListEqual(UpperCAmelCase_				,     UpperCAmelCase_					)

									_SCREAMING_SNAKE_CASE     				=  tokens + ["""<unk>"""]
									_SCREAMING_SNAKE_CASE     				=  [14, 15, 20]
									self.assertListEqual(tokenizer.convert_tokens_to_ids(UpperCAmelCase_					)				,     UpperCAmelCase_					)







			def 							UpperCamelCase				(     self:  Optional[Any]				,     UpperCAmelCase_:  Union[str, Any]=15					):







									'''simple docstring'''




									for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
															with self.subTest(F'{tokenizer.__class__.__name__} ({pretrained_name})'					):
																					_SCREAMING_SNAKE_CASE     				=  self.rust_tokenizer_class.from_pretrained(UpperCAmelCase_				,     **UpperCAmelCase_					)

																					# Simple input
																					_SCREAMING_SNAKE_CASE     				=  """This is a simple input"""
																					_SCREAMING_SNAKE_CASE     				=  ["""This is a simple input 1""", """This is a simple input 2"""]
																					_SCREAMING_SNAKE_CASE     				=  ("""This is a simple input""", """This is a pair""")
																					_SCREAMING_SNAKE_CASE     				=  [
																					    ("""This is a simple input 1""", """This is a simple input 2"""),
																					    ("""This is a simple pair 1""", """This is a simple pair 2"""),
																					]

																					# Simple input tests
																					self.assertRaises(UpperCAmelCase_				,     tokenizer_r.encode				,     UpperCAmelCase_				,     max_length=UpperCAmelCase_				,     padding="""max_length"""					)

																					# Simple input
																					self.assertRaises(UpperCAmelCase_				,     tokenizer_r.encode_plus				,     UpperCAmelCase_				,     max_length=UpperCAmelCase_				,     padding="""max_length"""					)

																					# Simple input
																					self.assertRaises(
																					    UpperCAmelCase_				,     tokenizer_r.batch_encode_plus				,     UpperCAmelCase_				,     max_length=UpperCAmelCase_				,     padding="""max_length"""				,     )

																					# Pair input
																					self.assertRaises(UpperCAmelCase_				,     tokenizer_r.encode				,     UpperCAmelCase_				,     max_length=UpperCAmelCase_				,     padding="""max_length"""					)

																					# Pair input
																					self.assertRaises(UpperCAmelCase_				,     tokenizer_r.encode_plus				,     UpperCAmelCase_				,     max_length=UpperCAmelCase_				,     padding="""max_length"""					)

																					# Pair input
																					self.assertRaises(
																					    UpperCAmelCase_				,     tokenizer_r.batch_encode_plus				,     UpperCAmelCase_				,     max_length=UpperCAmelCase_				,     padding="""max_length"""				,     )







			def 							UpperCamelCase				(     self:  List[Any]					):







									'''simple docstring'''




									pass



@require_ftfy
@require_spacy
@require_tokenizers
class 				__UpperCAmelCase		(_UpperCAmelCase   ):
			pass

