
    e                        d Z ddlZddlZddlmZ ddlmZ ddlm	Z	  ej
        d          Z
e	d             Ze	d             Zd	 Z ed
d
          Z ej        edeg                              d          Ze                     ej        dddd           ej        dddddd                     e
                    e          Zde_        dS )z
Example app demonstrating how to use the HoloViews API to generate
a bokeh app with complex interactivity. Uses a RangeXY stream to allow
interactive exploration of the mandelbrot set.
    N)opts)RangeXY)jitbokehc                     d}t          | |          }d}t          |          D ]1}||z  |z   }|j        |j        z  |j        |j        z  z   dk    r|c S 2dS )z
    Given the real and imaginary parts of a complex number,
    determine if it is a candidate for membership in the Mandelbrot
    set given a fixed number of iterations.
    r   y                      )complexrangerealimag)xy	max_itersiczs         Plib/python3.11/site-packages/holoviews/examples/gallery/apps/bokeh/mandelbrot.pymandelr      st     	
A!AA9  aC!GF16MAF16M)a//HHH 0 3    c                     |j         d         }|j         d         }|| z
  |z  }||z
  |z  }	t          |          D ]<}
| |
|z  z   }t          |          D ]"}|||	z  z   }t          |||          }||||
f<   #=|S )Nr      )shaper   r   )min_xmax_xmin_ymax_yimageitersheightwidthpixel_size_xpixel_size_yr   r   r   r   colors                  r   create_fractalr%   !   s    [^FKNEEMU*LEMV+L5\\    q<''v 	  	 A1|++D4u--EE!Q$KK	 
 Lr   c           
          | |c\  }}\  }}t          j        dt           j                  }t          j        t          ||| | |d          ||||f          S )N)X  r'   )dtype   )bounds)npzerosuint8hvImager%   )x_rangey_rangex0x1y0y1r   s          r   get_fractalr6   1   si     'HRhr2HZrx000E8N2rB3UC@@B+- - - -r   )g      g      ?)r0   r1   zManderbrot Explorer)labelstreamsT)logr)   )r   N)	framewiselogyr!   xlimfirer'   )cmaplogzr    r!   xaxisyaxiszMandelbrot Explorer)__doc__numpyr+   	holoviewsr.   r   holoviews.streamsr   numbar   rendererr   r%   r6   range_stream
DynamicMaphistdmap	Histogramr/   
server_docdoctitle r   r   <module>rQ      sp                  % % % % % %      2;w      - - - wy)<<< r}[(=*^- - --1TdT^^  		DNTCiHHHDJFc' ' '( ( (
 $!			r   