


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

import numpy
from matplotlib import pyplot

UpperCAmelCase__            =							0.25 + 0.0J
UpperCAmelCase__            =							-0.4 + 0.6J
UpperCAmelCase__            =							-0.1 + 0.6_51J
UpperCAmelCase__            =							-2.0
UpperCAmelCase__            =							56
UpperCAmelCase__            =							2.0
UpperCAmelCase__            =							666
def     UpperCAmelCase_ (							__snake_case					,						__snake_case						)					->      numpy.ndarray:







 """simple docstring"""


 return numpy.exp(__snake_case						) + c_parameter
def     UpperCAmelCase_ (							__snake_case					,						__snake_case						)					->      numpy.ndarray:







 """simple docstring"""


 return z_values * z_values + c_parameter
def     UpperCAmelCase_ (							__snake_case					,						__snake_case						)					->      numpy.ndarray:







 """simple docstring"""


 _lowercase											=numpy.linspace(-window_size					,						__snake_case					,						__snake_case						)
 _lowercase											=x.reshape((nb_pixels, 1)						)
 _lowercase											=numpy.linspace(-window_size					,						__snake_case					,						__snake_case						)
 _lowercase											=y.reshape((1, nb_pixels)						)
 return x + 1.0j * y
def     UpperCAmelCase_ (							__snake_case					,						__snake_case					,						__snake_case					,						__snake_case					,						__snake_case = None					,						)					->      numpy.ndarray:







 """simple docstring"""


 _lowercase											=z_a.astype('''complex64'''						)
 for _ in range(__snake_case						):
  _lowercase											=eval_function(__snake_case					,						__snake_case						)
  if infinity is not None:
   numpy.nan_to_num(__snake_case					,						copy=__snake_case					,						nan=__snake_case						)
   _lowercase											=infinity
 return z_n
def     UpperCAmelCase_ (							__snake_case					,						__snake_case					,						__snake_case					,						__snake_case					,						)					->      None:







 """simple docstring"""


 _lowercase											=(abs(__snake_case						)).transpose()
 _lowercase											=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     UpperCAmelCase_ (							)					->      None:







 """simple docstring"""


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


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

  ignore_overflow_warnings()  # See file header for explanations

  UpperCAmelCase__            =							24
  UpperCAmelCase__            =							2 * abs(c_cauliflower) + 1
  UpperCAmelCase__            =							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)

  UpperCAmelCase__            =							64
  UpperCAmelCase__            =							2 * abs(c_polynomial_a) + 1
  UpperCAmelCase__            =							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)

  UpperCAmelCase__            =							161
  UpperCAmelCase__            =							2 * abs(c_polynomial_a) + 1
  UpperCAmelCase__            =							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)

  UpperCAmelCase__            =							12
  UpperCAmelCase__            =							1_00_00.0
  UpperCAmelCase__            =							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)





UpperCAmelCase__            =							[
    [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
    [0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0],
    [0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0],
]
def     UpperCAmelCase_ (							__snake_case					,						__snake_case					,						__snake_case					,						__snake_case						)					->      bool:







 """simple docstring"""


 return 0 <= row < rows and 0 <= col < cols
def     UpperCAmelCase_ (							__snake_case					,						__snake_case					,						__snake_case					,						__snake_case						)					->      int:







 """simple docstring"""


 _lowercase											=len(__snake_case						)
 _lowercase											=len(mat[0]						)
 if is_safe(__snake_case					,						__snake_case					,						__snake_case					,						__snake_case						) and (row, col) not in seen and mat[row][col] == 1:
  seen.add((row, col)						)
  return (
      1
      + depth_first_search(row + 1					,						__snake_case					,						__snake_case					,						__snake_case						)
      + depth_first_search(row - 1					,						__snake_case					,						__snake_case					,						__snake_case						)
      + depth_first_search(__snake_case					,						col + 1					,						__snake_case					,						__snake_case						)
      + depth_first_search(__snake_case					,						col - 1					,						__snake_case					,						__snake_case						)
  )
 else:
  return 0
def     UpperCAmelCase_ (							__snake_case						)					->      int:







 """simple docstring"""


 _lowercase											=set()

 _lowercase											=0
 for row, line in enumerate(__snake_case						):
  for col, item in enumerate(__snake_case						):
   if item == 1 and (row, col) not in seen:
    # Maximizing the area
    _lowercase											=max(__snake_case					,						depth_first_search(__snake_case					,						__snake_case					,						__snake_case					,						__snake_case						)						)
 return max_area


if __name__ == "__main__":
  import doctest

  print(find_max_area(matrix))  # Output -> 6
  doctest.testmod()

