






"""simple docstring"""






import importlib.metadata
from typing import Union

from packaging.version import Version, parse

from .constants import STR_OPERATION_TO_FUNC


SCREAMING_SNAKE_CASE						:						Dict					   =       parse(importlib.metadata.version('''torch'''))



def  __lowerCamelCase					(					lowerCAmelCase__       ,lowerCAmelCase__       ,lowerCAmelCase__				):
				if operation not in STR_OPERATION_TO_FUNC.keys():
								raise ValueError(f'''`operation` must be one of {list(STR_OPERATION_TO_FUNC.keys()				)}, received {operation}'''				)
				A__							 =       STR_OPERATION_TO_FUNC[operation]
				if isinstance(lowerCAmelCase__       ,lowerCAmelCase__				):
								A__							 =       parse(importlib.metadata.version(lowerCAmelCase__				)				)
				return operation(lowerCAmelCase__       ,parse(lowerCAmelCase__				)				)







def  __lowerCamelCase					(					lowerCAmelCase__       ,lowerCAmelCase__				):
				return compare_versions(lowerCAmelCase__       ,lowerCAmelCase__       ,lowerCAmelCase__				)










"""simple docstring"""






from math import factorial, pi



def  __lowerCamelCase					(					lowerCAmelCase__       ,lowerCAmelCase__ = 30				):

				if not isinstance(lowerCAmelCase__       ,(int, float)				):
								raise ValueError('maclaurin_sin() requires either an int or float for theta'				)

				if not isinstance(lowerCAmelCase__       ,lowerCAmelCase__				) or accuracy <= 0:
								raise ValueError('maclaurin_sin() requires a positive int for accuracy'				)

				A__							 =       float(lowerCAmelCase__				)
				A__							 =       theta // (2 * pi)
				theta -= 2 * div * pi
				return sum(
				    (-1) ** r * theta ** (2 * r + 1) / factorial(2 * r + 1				) for r in range(lowerCAmelCase__				)				)



def  __lowerCamelCase					(					lowerCAmelCase__       ,lowerCAmelCase__ = 30				):

				if not isinstance(lowerCAmelCase__       ,(int, float)				):
								raise ValueError('maclaurin_cos() requires either an int or float for theta'				)

				if not isinstance(lowerCAmelCase__       ,lowerCAmelCase__				) or accuracy <= 0:
								raise ValueError('maclaurin_cos() requires a positive int for accuracy'				)

				A__							 =       float(lowerCAmelCase__				)
				A__							 =       theta // (2 * pi)
				theta -= 2 * div * pi
				return sum((-1) ** r * theta ** (2 * r) / factorial(2 * r				) for r in range(lowerCAmelCase__				)				)


if __name__ == "__main__":
					import doctest

					doctest.testmod()

					print(maclaurin_sin(10))
					print(maclaurin_sin(-10))
					print(maclaurin_sin(10, 15))
					print(maclaurin_sin(-10, 15))

					print(maclaurin_cos(5))
					print(maclaurin_cos(-5))
					print(maclaurin_cos(10, 15))
					print(maclaurin_cos(-10, 15))


