import warnings
from collections.abc import Callable
from typing import Any

import numpy
from matplotlib import pyplot

__lowerCamelCase :     Dict          =  0.25 + 0.0J
__lowerCamelCase :     Optional[Any]          =  -0.4 + 0.6J
__lowerCamelCase :     List[str]          =  -0.1 + 0.651J
__lowerCamelCase :     str          =  -2.0
__lowerCamelCase :     Any          =  56
__lowerCamelCase :     int          =  2.0
__lowerCamelCase :     Dict          =  6_66




def 				_snake_case     (       lowerCAmelCase							:       complex       ,			lowerCAmelCase							:       numpy.ndarray     ):
			"""simple docstring"""







			return numpy.exp(lowerCAmelCase     ) + c_parameter




def 				_snake_case     (       lowerCAmelCase							:       complex       ,			lowerCAmelCase							:       numpy.ndarray     ):
			"""simple docstring"""







			return z_values * z_values + c_parameter




def 				_snake_case     (       lowerCAmelCase							:       float       ,			lowerCAmelCase							:       int     ):
			"""simple docstring"""







			SCREAMING_SNAKE_CASE_  :		Dict    				=   numpy.linspace(-window_size       ,			lowerCAmelCase       ,			lowerCAmelCase     )
			SCREAMING_SNAKE_CASE_  :		Optional[int]    				=   x.reshape((nb_pixels, 1)     )
			SCREAMING_SNAKE_CASE_  :		List[Any]    				=   numpy.linspace(-window_size       ,			lowerCAmelCase       ,			lowerCAmelCase     )
			SCREAMING_SNAKE_CASE_  :		Union[str, Any]    				=   y.reshape((1, nb_pixels)     )
			return x + 1.0J * y




def 				_snake_case     (       lowerCAmelCase							:       Callable[[Any, numpy.ndarray], numpy.ndarray]       ,			lowerCAmelCase							:       Any       ,			lowerCAmelCase							:       int       ,			lowerCAmelCase							:       numpy.ndarray       ,			lowerCAmelCase							:       float | None = None       ,			):
			"""simple docstring"""







			SCREAMING_SNAKE_CASE_  :		List[str]    				=   z_a.astype("complex64"     )
			for _ in range(lowerCAmelCase     ):
						SCREAMING_SNAKE_CASE_  :		List[str]    				=   eval_function(lowerCAmelCase       ,			lowerCAmelCase     )
						if infinity is not None:
									numpy.nan_to_num(lowerCAmelCase       ,			copy=lowerCAmelCase       ,			nan=lowerCAmelCase     )
									SCREAMING_SNAKE_CASE_  :		Any    				=   infinity
			return z_n




def 				_snake_case     (       lowerCAmelCase							:       str       ,			lowerCAmelCase							:       Any       ,			lowerCAmelCase							:       float       ,			lowerCAmelCase							:       numpy.ndarray       ,			):
			"""simple docstring"""







			SCREAMING_SNAKE_CASE_  :		Tuple    				=   (abs(lowerCAmelCase     )).transpose()
			SCREAMING_SNAKE_CASE_  :		int    				=   abs_z_final[::-1, :]
			pyplot.matshow(abs_z_final < escape_radius     )
			pyplot.title(f'Julia set of ${function_label}$, $c={function_params}$'     )
			pyplot.show()




def 				_snake_case     (       ):
			"""simple docstring"""







			warnings.filterwarnings(
			    "ignore"       ,			category=lowerCAmelCase       ,			message="overflow encountered in multiply"     )
			warnings.filterwarnings(
			    "ignore"       ,			category=lowerCAmelCase       ,			message="invalid value encountered in multiply"       ,			)
			warnings.filterwarnings(
			    "ignore"       ,			category=lowerCAmelCase       ,			message="overflow encountered in absolute"     )
			warnings.filterwarnings(
			    "ignore"       ,			category=lowerCAmelCase       ,			message="overflow encountered in exp"     )


if __name__ == "__main__":
		__lowerCamelCase :     int          =  prepare_grid(window_size, nb_pixels)

		ignore_overflow_warnings()  # See file header for explanations

		__lowerCamelCase :     Any          =  24
		__lowerCamelCase :     Any          =  2 * abs(c_cauliflower) + 1
		__lowerCamelCase :     Dict          =  iterate_function(
		    eval_quadratic_polynomial,
		    c_cauliflower,
		    nb_iterations,
		    z_a,
		    infinity=1.1 * escape_radius,
		)
		show_results('''z^2+c''', c_cauliflower, escape_radius, z_final)

		__lowerCamelCase :     str          =  64
		__lowerCamelCase :     Any          =  2 * abs(c_polynomial_a) + 1
		__lowerCamelCase :     Dict          =  iterate_function(
		    eval_quadratic_polynomial,
		    c_polynomial_a,
		    nb_iterations,
		    z_a,
		    infinity=1.1 * escape_radius,
		)
		show_results('''z^2+c''', c_polynomial_a, escape_radius, z_final)

		__lowerCamelCase :     Dict          =  1_61
		__lowerCamelCase :     List[str]          =  2 * abs(c_polynomial_a) + 1
		__lowerCamelCase :     List[str]          =  iterate_function(
		    eval_quadratic_polynomial,
		    c_polynomial_a,
		    nb_iterations,
		    z_a,
		    infinity=1.1 * escape_radius,
		)
		show_results('''z^2+c''', c_polynomial_a, escape_radius, z_final)

		__lowerCamelCase :     Dict          =  12
		__lowerCamelCase :     Tuple          =  10000.0
		__lowerCamelCase :     List[Any]          =  iterate_function(
		    eval_exponential,
		    c_exponential,
		    nb_iterations,
		    z_a + 2,
		    infinity=1.0E10,
		)
		show_results('''e^z+c''', c_exponential, escape_radius, z_final)

__lowerCamelCase :     List[Any]          =  {hex(i)[2:]: i for i in range(16)}  # Use [:2] to strip off the leading '0x'




def 				_snake_case     (       lowerCAmelCase							:       str     ):
		"""simple docstring"""







		SCREAMING_SNAKE_CASE_  :		Optional[Any]    				=   hex_string.strip().lower()
		if not hex_string:
				raise ValueError("Empty string was passed to the function"     )
		SCREAMING_SNAKE_CASE_  :		str    				=   hex_string[0] == "-"
		if is_negative:
				SCREAMING_SNAKE_CASE_  :		Optional[int]    				=   hex_string[1:]
		if not all(char in hex_table for char in hex_string     ):
				raise ValueError("Non-hexadecimal value was passed to the function"     )
		SCREAMING_SNAKE_CASE_  :		List[Any]    				=   0
		for char in hex_string:
				SCREAMING_SNAKE_CASE_  :		Tuple    				=   1_6 * decimal_number + hex_table[char]
		return -decimal_number if is_negative else decimal_number


if __name__ == "__main__":
		from doctest import testmod

		testmod()
