import numpy as np

from matplotlib import pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = [15, 5]
plt.rcParams['figure.dpi'] = 100

from numba import jit, vectorize, guvectorize, float64, complex64, int32, float32

def mandelbrot_set(xmin,xmax,ymin,ymax,width,height,maxiter, mandelbrot_func, real=False):
    r1 = np.linspace(xmin, xmax, width)
    r2 = np.linspace(ymin, ymax, height)
    if real:
        return [[mandelbrot_func(r, i, maxiter) for r in r1] for i in r2]
    return [[mandelbrot_func(complex(r, i), maxiter) for r in r1] for i in r2]

male_hodnoty = (-2.0,0.5,-1.25,1.25,1000,1000,80)
velke_hodnoty = (-0.74877,-0.74872,0.06505,0.06510,1000,1000,2048)
    
def pds_zobraz(f, real=False):
    %time plt.subplot(1, 2, 1).imshow(mandelbrot_set(*male_hodnoty, f, real))
    %time plt.subplot(1, 2, 2).imshow(mandelbrot_set(*velke_hodnoty, f, real))
    
def mandelbrot_python(z, maxiter):
    c = z
    for n in range(maxiter):
        if abs(z) > 2:
            return n
        z = z*z + c
    return maxiter
