




"""simple docstring"""





import functools
from math import sqrt
from time import time

def 		lowerCAmelCase				(			lowerCamelCase   ,      *lowerCamelCase   ,      **lowerCamelCase		):
						'''simple docstring'''


						snake_case__							:       str				      =       time()
						snake_case__							:       Union[str, Any]				      =       func(*SCREAMING_SNAKE_CASE__   ,      **SCREAMING_SNAKE_CASE__		)
						snake_case__							:       Tuple				      =       time()
						if int(end - start		) > 0:
												print(f'''{func.__name__} runtime: {(end - start):0.4f} s'''		)
						else:
												print(f'''{func.__name__} runtime: {(end - start) * 1000:0.4f} ms'''		)
						return output

def 		lowerCAmelCase				(			lowerCamelCase		):
						'''simple docstring'''


						if n < 0:
												raise Exception('''n is negative'''		)
						if n == 0:
												return [0]
						snake_case__							:       int				      =       [0, 1]
						for _ in range(n - 1		):
												fib.append(fib[-1] + fib[-2]		)
						return fib

def 		lowerCAmelCase				(			lowerCamelCase		):
						'''simple docstring'''


						def fib_recursive_term(lowerCamelCase		) -> int:
												if i < 0:
																		raise Exception('''n is negative'''		)
												if i < 2:
																		return i
												return fib_recursive_term(i - 1		) + fib_recursive_term(i - 2		)

						if n < 0:
												raise Exception('''n is negative'''		)
						return [fib_recursive_term(SCREAMING_SNAKE_CASE__		) for i in range(n + 1		)]

def 		lowerCAmelCase				(			lowerCamelCase		):
						'''simple docstring'''


						@functools.cache
						def fib_recursive_term(lowerCamelCase		) -> int:
												if i < 0:
																		raise Exception('''n is negative'''		)
												if i < 2:
																		return i
												return fib_recursive_term(i - 1		) + fib_recursive_term(i - 2		)

						if n < 0:
												raise Exception('''n is negative'''		)
						return [fib_recursive_term(SCREAMING_SNAKE_CASE__		) for i in range(n + 1		)]

def 		lowerCAmelCase				(			lowerCamelCase		):
						'''simple docstring'''


						if n < 0:
												raise Exception('''n is negative'''		)
						# Cache must be outside recursuive function
						# other it will reset every time it calls itself.
						snake_case__							:       List[Any]				      =       {0: 0, 1: 1, 2: 1}  # Prefilled cache

						def rec_fn_memoized(lowerCamelCase		) -> int:
												if num in cache:
																		return cache[num]

												snake_case__							:       List[str]				      =       rec_fn_memoized(num - 1		) + rec_fn_memoized(num - 2		)
												snake_case__							:       Union[str, Any]				      =       value
												return value

						return [rec_fn_memoized(SCREAMING_SNAKE_CASE__		) for i in range(n + 1		)]

def 		lowerCAmelCase				(			lowerCamelCase		):
						'''simple docstring'''


						if n < 0:
												raise Exception('''n is negative'''		)
						if n >= 1475:
												raise Exception('''n is too large'''		)
						snake_case__							:       str				      =       sqrt(5		)
						snake_case__							:       Optional[int]				      =       (1 + sqrt_a) / 2
						return [round(phi**i / sqrt_a		) for i in range(n + 1		)]


if __name__ == "__main__":
							_lowercase						   =     30
							time_func(fib_iterative, num)
							time_func(fib_recursive, num)  # Around 3s runtime
							time_func(fib_recursive_cached, num)  # Around 0ms runtime
							time_func(fib_memoization, num)
							time_func(fib_binet, num)





import math
import os

import cva
import numpy as np

lowercase_									=    255.0
def 		_snake_case(       SCREAMING_SNAKE_CASE__     :      float       ,     SCREAMING_SNAKE_CASE__     :      float )				-> float:





    '''simple docstring'''






    A__        =  np.mean((original - contrast) ** 2 )
    if mse == 0:
        return 100

    return 20 * math.logaa(PIXEL_MAX / math.sqrt(SCREAMING_SNAKE_CASE__ ) )
def 		_snake_case(       )				-> None:





    '''simple docstring'''






    A__        =  os.path.dirname(os.path.realpath(SCREAMING_SNAKE_CASE__ ) )
    # Loading images (original image and compressed image)
    A__        =  cva.imread(os.path.join(SCREAMING_SNAKE_CASE__       ,     'image_data/original_image.png' ) )
    A__        =  cva.imread(os.path.join(SCREAMING_SNAKE_CASE__       ,     'image_data/compressed_image.png' )       ,     1 )

    A__        =  cva.imread(os.path.join(SCREAMING_SNAKE_CASE__       ,     'image_data/PSNR-example-base.png' ) )
    A__        =  cva.imread(
        os.path.join(SCREAMING_SNAKE_CASE__       ,     '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(SCREAMING_SNAKE_CASE__       ,     SCREAMING_SNAKE_CASE__ )} dB' )

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


if __name__ == "__main__":
     main()

