"""simple docstring"""







from math import pi, sqrt, tan
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if side_length < 0:
		raise ValueError('surface_area_cube() only accepts non-negative values'						)
	return 6 * side_length**2
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float    ,							UpperCAmelCase_					:       float    ,							UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if length < 0 or breadth < 0 or height < 0:
		raise ValueError('surface_area_cuboid() only accepts non-negative values'						)
	return 2 * ((length * breadth) + (breadth * height) + (length * height))
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if radius < 0:
		raise ValueError('surface_area_sphere() only accepts non-negative values'						)
	return 4 * pi * radius**2
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if radius < 0:
		raise ValueError('surface_area_hemisphere() only accepts non-negative values'						)
	return 3 * pi * radius**2
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float    ,							UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if radius < 0 or height < 0:
		raise ValueError('surface_area_cone() only accepts non-negative values'						)
	return pi * radius * (radius + (height**2 + radius**2) ** 0.5)
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float    ,							UpperCAmelCase_					:       float    ,							UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if radius_a < 0 or radius_a < 0 or height < 0:
		raise ValueError(
		    'surface_area_conical_frustum() only accepts non-negative values'						)
	__snake_case    :							str   	=				(height**2 + (radius_a - radius_a) ** 2) ** 0.5
	return pi * ((slant_height * (radius_a + radius_a)) + radius_a**2 + radius_a**2)
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float    ,							UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if radius < 0 or height < 0:
		raise ValueError('surface_area_cylinder() only accepts non-negative values'						)
	return 2 * pi * radius * (height + radius)
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float    ,							UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if torus_radius < 0 or tube_radius < 0:
		raise ValueError('surface_area_torus() only accepts non-negative values'						)
	if torus_radius < tube_radius:
		raise ValueError(
		    'surface_area_torus() does not support spindle or self intersecting tori'						)
	return 4 * pow(UpperCAmelCase_    ,							2						) * torus_radius * tube_radius
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float    ,							UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if length < 0 or width < 0:
		raise ValueError('area_rectangle() only accepts non-negative values'						)
	return length * width
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if side_length < 0:
		raise ValueError('area_square() only accepts non-negative values'						)
	return side_length**2
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float    ,							UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if base < 0 or height < 0:
		raise ValueError('area_triangle() only accepts non-negative values'						)
	return (base * height) / 2
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float    ,							UpperCAmelCase_					:       float    ,							UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if sidea < 0 or sidea < 0 or sidea < 0:
		raise ValueError('area_triangle_three_sides() only accepts non-negative values'						)
	elif sidea + sidea < sidea or sidea + sidea < sidea or sidea + sidea < sidea:
		raise ValueError('Given three sides do not form a triangle'						)
	__snake_case    :							List[Any]   	=				(sidea + sidea + sidea) / 2
	__snake_case    :							Optional[int]   	=				sqrt(
	    semi_perimeter
	    * (semi_perimeter - sidea)
	    * (semi_perimeter - sidea)
	    * (semi_perimeter - sidea)						)
	return area
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float    ,							UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if base < 0 or height < 0:
		raise ValueError('area_parallelogram() only accepts non-negative values'						)
	return base * height
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float    ,							UpperCAmelCase_					:       float    ,							UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if basea < 0 or basea < 0 or height < 0:
		raise ValueError('area_trapezium() only accepts non-negative values'						)
	return 1 / 2 * (basea + basea) * height
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if radius < 0:
		raise ValueError('area_circle() only accepts non-negative values'						)
	return pi * radius**2
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float    ,							UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if radius_x < 0 or radius_y < 0:
		raise ValueError('area_ellipse() only accepts non-negative values'						)
	return pi * radius_x * radius_y
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       float    ,							UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if diagonal_a < 0 or diagonal_a < 0:
		raise ValueError('area_rhombus() only accepts non-negative values'						)
	return 1 / 2 * diagonal_a * diagonal_a
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       int    ,							UpperCAmelCase_					:       float						)							->    float:

	'''simple docstring'''





	if not isinstance(UpperCAmelCase_    ,							UpperCAmelCase_						) or sides < 3:
		raise ValueError(
		    'area_reg_polygon() only accepts integers greater than or \
equal to three as number of sides'						)
	elif length < 0:
		raise ValueError(
		    'area_reg_polygon() only accepts non-negative values as \
length of a side'						)
	return (sides * length**2) / (4 * tan(pi / sides						))
	return (sides * length**2) / (4 * tan(pi / sides						))


if __name__ == "__main__":
	import doctest

	doctest.testmod(verbose=True)  # verbose so we can see methods missing tests

	print("[DEMO] Areas of various geometric shapes: \n")
	print(f'''Rectangle: {area_rectangle(10, 20) = }''')
	print(f'''Square: {area_square(10) = }''')
	print(f'''Triangle: {area_triangle(10, 10) = }''')
	print(f'''Triangle: {area_triangle_three_sides(5, 12, 13) = }''')
	print(f'''Parallelogram: {area_parallelogram(10, 20) = }''')
	print(f'''Rhombus: {area_rhombus(10, 20) = }''')
	print(f'''Trapezium: {area_trapezium(10, 20, 30) = }''')
	print(f'''Circle: {area_circle(20) = }''')
	print(f'''Ellipse: {area_ellipse(10, 20) = }''')
	print("\nSurface Areas of various geometric shapes: \n")
	print(f'''Cube: {surface_area_cube(20) = }''')
	print(f'''Cuboid: {surface_area_cuboid(10, 20, 30) = }''')
	print(f'''Sphere: {surface_area_sphere(20) = }''')
	print(f'''Hemisphere: {surface_area_hemisphere(20) = }''')
	print(f'''Cone: {surface_area_cone(10, 20) = }''')
	print(f'''Conical Frustum: {surface_area_conical_frustum(10, 20, 30) = }''')
	print(f'''Cylinder: {surface_area_cylinder(10, 20) = }''')
	print(f'''Torus: {surface_area_torus(20, 10) = }''')
	print(f'''Equilateral Triangle: {area_reg_polygon(3, 10) = }''')
	print(f'''Square: {area_reg_polygon(4, 10) = }''')
	print(f'''Reqular Pentagon: {area_reg_polygon(5, 10) = }''')






"""simple docstring"""







import argparse
from collections import defaultdict

import yaml


_a  :  Tuple=				"docs/source/en/_toctree.yml"
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       Optional[Any]						)							->    Dict:

	'''simple docstring'''





	__snake_case    :							Union[str, Any]   	=				defaultdict(UpperCAmelCase_						)
	__snake_case    :							List[str]   	=				[]
	__snake_case    :							Tuple   	=				[]
	for doc in doc_list:
		if "local" in doc:
			counts[doc["local"]] += 1

		if doc["title"].lower() == "overview":
			overview_doc.append({'local': doc['local'], 'title': doc['title']}						)
		else:
			new_doc_list.append(UpperCAmelCase_						)

	__snake_case    :							Any   	=				new_doc_list
	__snake_case    :							Dict   	=				[key for key, value in counts.items() if value > 1]

	__snake_case    :							Optional[int]   	=				[]
	for duplicate_key in duplicates:
		__snake_case    :							Tuple   	=				list({doc['title'] for doc in doc_list if doc['local'] == duplicate_key}						)
		if len(UpperCAmelCase_						) > 1:
			raise ValueError(
			    F"{duplicate_key} is present several times in the documentation table of content at "
			    '`docs/source/en/_toctree.yml` with different *Title* values. Choose one of those and remove the '
			    'others.'						)
		# Only add this once
		new_doc.append({'local': duplicate_key, 'title': titles[0]}						)

	# Add none duplicate-keys
	new_doc.extend([doc for doc in doc_list if 'local' not in counts or counts[doc['local']] == 1]						)
	__snake_case    :							List[Any]   	=				sorted(UpperCAmelCase_    ,							key=lambda UpperCAmelCase_						: s["title"].lower()						)

	# "overview" gets special treatment and is always first
	if len(UpperCAmelCase_						) > 1:
		raise ValueError('{doc_list} has two \'overview\' docs which is not allowed.'						)

	overview_doc.extend(UpperCAmelCase_						)

	# Sort
	return overview_doc
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       Optional[int]=False						)							->    str:

	'''simple docstring'''





	with open(UpperCAmelCase_    ,							encoding='utf-8'						) as f:
		__snake_case    :							List[Any]   	=				yaml.safe_load(f.read()						)

	# Get to the API doc
	__snake_case    :							str   	=				0
	while content[api_idx]["title"] != "API":
		api_idx += 1
	__snake_case    :							Union[str, Any]   	=				content[api_idx]['sections']

	# Then to the model doc
	__snake_case    :							Dict   	=				0
	while api_doc[scheduler_idx]["title"] != "Schedulers":
		scheduler_idx += 1

	__snake_case    :							Optional[Any]   	=				api_doc[scheduler_idx]['sections']
	__snake_case    :							Tuple   	=				clean_doc_toc(UpperCAmelCase_						)

	__snake_case    :							Tuple   	=				False
	if new_scheduler_doc != scheduler_doc:
		__snake_case    :							Optional[int]   	=				True
		if overwrite:
			__snake_case    :							Tuple   	=				new_scheduler_doc

	if diff:
		if overwrite:
			__snake_case    :							Optional[int]   	=				api_doc
			with open(UpperCAmelCase_    ,							'w'    ,							encoding='utf-8'						) as f:
				f.write(yaml.dump(UpperCAmelCase_    ,							allow_unicode=UpperCAmelCase_						)						)
		else:
			raise ValueError(
			    'The model doc part of the table of content is not properly sorted, run `make style` to fix this.'						)
def 						__UpperCAmelCase       (					UpperCAmelCase_					:       Any=False						)							->    Union[str, Any]:

	'''simple docstring'''





	with open(UpperCAmelCase_    ,							encoding='utf-8'						) as f:
		__snake_case    :							Dict   	=				yaml.safe_load(f.read()						)

	# Get to the API doc
	__snake_case    :							Dict   	=				0
	while content[api_idx]["title"] != "API":
		api_idx += 1
	__snake_case    :							Dict   	=				content[api_idx]['sections']

	# Then to the model doc
	__snake_case    :							Dict   	=				0
	while api_doc[pipeline_idx]["title"] != "Pipelines":
		pipeline_idx += 1

	__snake_case    :							Optional[int]   	=				False
	__snake_case    :							Optional[Any]   	=				api_doc[pipeline_idx]['sections']
	__snake_case    :							Tuple   	=				[]

	# sort sub pipeline docs
	for pipeline_doc in pipeline_docs:
		if "section" in pipeline_doc:
			__snake_case    :							List[str]   	=				pipeline_doc['section']
			__snake_case    :							Optional[int]   	=				clean_doc_toc(UpperCAmelCase_						)
			if overwrite:
				__snake_case    :							List[Any]   	=				new_sub_pipeline_doc
		new_pipeline_docs.append(UpperCAmelCase_						)

	# sort overall pipeline doc
	__snake_case    :							List[Any]   	=				clean_doc_toc(UpperCAmelCase_						)

	if new_pipeline_docs != pipeline_docs:
		__snake_case    :							Dict   	=				True
		if overwrite:
			__snake_case    :							Tuple   	=				new_pipeline_docs

	if diff:
		if overwrite:
			__snake_case    :							Union[str, Any]   	=				api_doc
			with open(UpperCAmelCase_    ,							'w'    ,							encoding='utf-8'						) as f:
				f.write(yaml.dump(UpperCAmelCase_    ,							allow_unicode=UpperCAmelCase_						)						)
		else:
			raise ValueError(
			    'The model doc part of the table of content is not properly sorted, run `make style` to fix this.'						)


if __name__ == "__main__":
	_a  :  Optional[int]=				argparse.ArgumentParser()
	parser.add_argument("--fix_and_overwrite", action="store_true", help="Whether to fix inconsistencies.")
	_a  :  List[str]=				parser.parse_args()

	check_scheduler_doc(args.fix_and_overwrite)
	check_pipeline_doc(args.fix_and_overwrite)





