




'''simple docstring'''




import math
import os

import cva
import numpy as np

snake_case__          =						2_5_5.0




def 						snake_case__    ( lowerCamelCase__				:   float			,		lowerCamelCase__				:   float			)   ->   float:
					A_ :     Union[str, Any] =							np.mean((original - contrast) ** 2			)
					if mse == 0:
										return 1_0_0

					return 2_0 * math.logaa(PIXEL_MAX / math.sqrt(lowerCamelCase__			)			)




def 						snake_case__    ( )   ->   None:
					A_ :     Optional[Any] =							os.path.dirname(os.path.realpath(lowerCamelCase__			)			)
					# Loading images (original image and compressed image)
					A_ :     Tuple =							cva.imread(os.path.join(lowerCamelCase__			,		'''image_data/original_image.png'''			)			)
					A_ :     Optional[Any] =							cva.imread(os.path.join(lowerCamelCase__			,		'''image_data/compressed_image.png'''			)			,		1			)

					A_ :     Optional[int] =							cva.imread(os.path.join(lowerCamelCase__			,		'''image_data/PSNR-example-base.png'''			)			)
					A_ :     Any =							cva.imread(
					    os.path.join(lowerCamelCase__			,		'''image_data/PSNR-example-comp-10.jpg'''			)			,		1			)

					# Value expected: 29.73dB
					print('''-- First Test --'''			)
					print(f'PSNR value is {peak_signal_to_noise_ratio(lowerCamelCase__			,		lowerCamelCase__			)} dB'			)

					# # Value expected: 31.53dB (Wikipedia Example)
					print('''\n-- Second Test --'''			)
					print(f'PSNR value is {peak_signal_to_noise_ratio(lowerCamelCase__			,		lowerCamelCase__			)} dB'			)


if __name__ == "__main__":
							main()









'''simple docstring'''




def 						snake_case__    ( lowerCamelCase__				:   float			)   ->   float:
					return -num if num < 0 else num




def 						snake_case__    ( lowerCamelCase__				:   list[int]			)   ->   int:
					if len(lowerCamelCase__			) == 0:
										raise ValueError('''abs_min() arg is an empty sequence'''			)
					A_ :     Any =							x[0]
					for i in x:
										if abs_val(lowerCamelCase__			) < abs_val(lowerCamelCase__			):
															A_ :     Tuple =							i
					return j




def 						snake_case__    ( lowerCamelCase__				:   list[int]			)   ->   int:
					if len(lowerCamelCase__			) == 0:
										raise ValueError('''abs_max() arg is an empty sequence'''			)
					A_ :     List[str] =							x[0]
					for i in x:
										if abs(lowerCamelCase__			) > abs(lowerCamelCase__			):
															A_ :     Any =							i
					return j




def 						snake_case__    ( lowerCamelCase__				:   list[int]			)   ->   int:
					if len(lowerCamelCase__			) == 0:
										raise ValueError('''abs_max_sort() arg is an empty sequence'''			)
					return sorted(lowerCamelCase__			,		key=lowerCamelCase__			)[-1]




def 						snake_case__    ( )   ->   Optional[Any]:
					assert abs_val(0			) == 0
					assert abs_val(3_4			) == 3_4
					assert abs_val(-1_0_0_0_0_0_0_0_0_0_0_0			) == 1_0_0_0_0_0_0_0_0_0_0_0

					A_ :     Dict =							[-3, -1, 2, -1_1]
					assert abs_max(lowerCamelCase__			) == -1_1
					assert abs_max_sort(lowerCamelCase__			) == -1_1
					assert abs_min(lowerCamelCase__			) == -1


if __name__ == "__main__":
							import doctest

							doctest.testmod()

							test_abs_val()
							print(abs_val(-34))  # --> 34



