Ë
    ¨2Úi6  ã                  ó  — d dl mZ d dlZd dlmZmZ d dlmZmZm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ d d	lmZ d dlZd d
lmZmZ d dlmZmZ d dlmZmZ d dlm Z  er d dl!m"Z" d dlm#Z# d dl$m%Z% d dl&m'Z' d dl(m)Z)m*Z*  G d„ de «      Z+y)é    )ÚannotationsN)ÚTYPE_CHECKINGÚAny)Ú
export_pngÚ
export_svgÚshow)Úget_screenshot_as_png)Úgridplot)ÚLabel)Ú
Category10)Úfigure)ÚFillTypeÚLineType)Úas_fill_typeÚas_line_type)Úfilled_to_bokehÚlines_to_bokeh)ÚRenderer)ÚGridPlot)ÚPalette)Ú	ArrayLike)Ú	WebDriver)Ú
FillReturnÚ
LineReturnc                  óŒ  — e Zd ZU dZded<   ded<   ded<   ded	<   	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 dd
„Zdd„Zdd„Z	 	 	 d	 	 	 	 	 	 	 	 	 	 	 dd„Z	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z		 	 	 	 d 	 	 	 	 	 	 	 	 	 	 	 	 	 d!d„Z
	 	 d"	 	 	 	 	 	 	 	 	 	 	 d#d„Z	 d$ddœ	 	 	 	 	 	 	 d%d„Zddœd&d„Zd'd„Zd(d)d„Z	 	 	 	 d*	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d+d„Zy),ÚBokehRendereraF  Utility renderer using Bokeh to render a grid of plots over the same (x, y) range.

    Args:
        nrows (int, optional): Number of rows of plots, default ``1``.
        ncols (int, optional): Number of columns of plots, default ``1``.
        figsize (tuple(float, float), optional): Figure size in inches (assuming 100 dpi), default
            ``(9, 9)``.
        show_frame (bool, optional): Whether to show frame and axes ticks, default ``True``.
        want_svg (bool, optional): Whether output is required in SVG format or not, default
            ``False``.

    Warning:
        :class:`~contourpy.util.bokeh_renderer.BokehRenderer`, unlike
        :class:`~contourpy.util.mpl_renderer.MplRenderer`, needs to be told in advance if output to
        SVG format will be required later, otherwise it will assume PNG output.
    zlist[figure]Ú_figuresr   Ú_layoutr   Ú_paletteÚboolÚ	_want_svgc                óà  — || _         t        d   | _        dt        j                  |t
        ¬«      z  }||z  }g | _        | j                   rdnd}t        |«      D ]f  }	t        |¬«      }
d|
j                  _
        d|
j                  _
        | j                  j                  |
«       |rŒOd |
_        d|
j                  _
        Œh t        | j                  |d |d   |z  |d	   |z  ¬
«      | _        y )Né
   éd   )ÚdtypeÚsvgÚcanvas)Úoutput_backendFr   é   )ÚncolsÚtoolbar_locationÚwidthÚheight)r!   r   r   ÚnpÚasarrayÚintr   Úranger   ÚxgridÚvisibleÚygridÚappendÚoutline_line_colorÚaxisr
   r   )ÚselfÚnrowsr*   ÚfigsizeÚ
show_frameÚwant_svgÚ
total_sizeÚnfiguresÚbackendÚ_Úfigs              úT/var/www/html/acx/venv/lib/python3.12/site-packages/contourpy/util/bokeh_renderer.pyÚ__init__zBokehRenderer.__init__2   s×   € ð "ˆŒÜ" 2™ˆŒàœŸ™ G´3Ô7Ñ7ˆ
à˜‘;ˆØˆŒØŸ>š>‘%¨xˆÜ�x“ò 	)ˆAÜ¨Ô0ˆCØ %ˆC�I‰IÔØ %ˆC�I‰IÔØ�M‰M× Ñ  Ô%ÚØ)-�Ô&Ø#(�—‘Õ ð	)ô  Ø�M‰M ¸Ø˜Q‘- 5Ñ(°¸A±À%Ñ1GôIˆ�ó    c                óp   — t        |t        «      r%|d   dk(  rt        |dd  «      }| j                  |   }|S )Nr   ÚCr)   )Ú
isinstanceÚstrr0   r   )r8   ÚcolorÚindexs      rB   Ú_convert_colorzBokehRenderer._convert_colorO   s8   € Ü�eœSÔ! e¨A¡h°#¢oÜ˜˜a˜b˜	“NˆEØ—M‘M %Ñ(ˆEØˆrD   c                óD   — t        |t        «      r| j                  |   }|S )N)rG   r0   r   )r8   Úaxs     rB   Ú_get_figurezBokehRenderer._get_figureU   s   € Ü�bœ#ÔØ—‘˜rÑ"ˆBØˆ	rD   c                óÊ   — t        |«      }| j                  |«      }| j                  |«      }t        ||«      \  }}t	        |«      dkD  r|j                  |g|g||d¬«       yy)a	  Plot filled contours on a single plot.

        Args:
            filled (sequence of arrays): Filled contour data as returned by
                :func:`~contourpy.ContourGenerator.filled`.
            fill_type (FillType or str): Type of ``filled`` data as returned by
                :attr:`~contourpy.ContourGenerator.fill_type`, or a string equivalent.
            ax (int or Bokeh Figure, optional): Which plot to use, default ``0``.
            color (str, optional): Color to plot with. May be a string color or the letter ``"C"``
                followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the
                ``Category10`` palette. Default ``"C0"``.
            alpha (float, optional): Opacity to plot with, default ``0.7``.
        r   )ÚxsÚysrI   Ú
fill_alphaÚ
line_widthN)r   rN   rK   r   ÚlenÚmulti_polygons)	r8   ÚfilledÚ	fill_typerM   rI   ÚalpharA   rP   rQ   s	            rB   rV   zBokehRenderer.filledZ   sl   € ô* ! Ó+ˆ	Ø×Ñ˜rÓ"ˆØ×#Ñ# EÓ*ˆÜ  ¨Ó3‰ˆˆBÜˆr‹7�QŠ;Ø×Ñ 2 $¨B¨4°uÈÐ[\ÐÕ]ð rD   Nc                óö  — | j                  |«      }| j                  ||«      \  }}|D �	cg c]  }	|	‘Œ c}	|j                  D �	cg c]  }	|	‘Œ c}	z   }
|D �	cg c]  }	|	‘Œ c}	|j                  D �	cg c]  }	|	‘Œ c}	z   }t        ||¬«      } |j                  |
|fi |¤Ž |dkD  �rød|dd…dd…f   |dd…dd…f   z   |dd…dd…f   z   |dd…dd…f   z   z  j                  «       }d|dd…dd…f   |dd…dd…f   z   |dd…dd…f   z   |dd…dd…f   z   z  j                  «       } |j                  t        j                  |dd…dd…f   j                  «       ||dd…dd…f   j                  «       fd¬«      D �	cg c]  }	|	‘Œ c}	t        j                  |dd…dd…f   j                  «       ||dd…dd…f   j                  «       fd¬«      D �	cg c]  }	|	‘Œ c}	fi |¤Ž  |j                  t        j                  |dd…dd…f   j                  «       ||dd…dd…f   j                  «       fd¬«      D �	cg c]  }	|	‘Œ c}	t        j                  |dd…dd…f   j                  «       ||dd…dd…f   j                  «       fd¬«      D �	cg c]  }	|	‘Œ c}	fi |¤Ž |�4|j                  |j                  «       |j                  «       |d|d¬	«       yyc c}	w c c}	w c c}	w c c}	w c c}	w c c}	w c c}	w c c}	w )
a  Plot quad grid lines on a single plot.

        Args:
            x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points.
            y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points.
            ax (int or Bokeh Figure, optional): Which plot to use, default ``0``.
            color (str, optional): Color to plot grid lines, default ``"black"``.
            alpha (float, optional): Opacity to plot lines with, default ``0.1``.
            point_color (str, optional): Color to plot grid points or ``None`` if grid points
                should not be plotted, default ``None``.
            quad_as_tri_alpha (float, optional): Opacity to plot ``quad_as_tri`` grid, default
                ``0``.

        Colors may be a string color or the letter ``"C"`` followed by an integer in the range
        ``"C0"`` to ``"C9"`` to use a color from the ``Category10`` palette.

        Warning:
            ``quad_as_tri_alpha > 0`` plots all quads as though they are unmasked.
        )Ú
line_colorrX   r   g      Ð?Néÿÿÿÿr)   )r7   é   )ÚxÚyÚ
fill_colorrZ   rX   Úsize)	rN   Ú_grid_as_2dÚTÚdictÚ
multi_lineÚravelr.   ÚstackÚcircle)r8   r]   r^   rM   rI   rX   Úpoint_colorÚquad_as_tri_alpharA   ÚrowrP   rQ   ÚkwargsÚxmidÚymids                  rB   ÚgridzBokehRenderer.gridv   s  € ð: ×Ñ˜rÓ"ˆØ×Ñ  1Ó%‰ˆˆ1ØÖ�cŠcÒ°!·#±#Ö"6¨3¢3Ò"6Ñ6ˆØÖ�cŠcÒ°!·#±#Ö"6¨3¢3Ò"6Ñ6ˆÜ ¨eÔ4ˆØˆ�‰�r˜2Ñ( Ò(Ø˜qÓ à˜!˜C˜R˜C  " ˜H™+¨¨!©"¨c¨r¨c¨'©
Ñ2°Q°s¸°s¸A¹B°w±ZÑ?À!ÀAÁBÈÉÀFÁ)ÑKÑL×SÑSÓUˆDØ˜!˜C˜R˜C  " ˜H™+¨¨!©"¨c¨r¨c¨'©
Ñ2°Q°s¸°s¸A¹B°w±ZÑ?À!ÀAÁBÈÉÀFÁ)ÑKÑL×SÑSÓUˆDØˆC�N‰NÜ "§¡¨!¨C¨R¨C°°"°¨H©+×*;Ñ*;Ó*=¸tÀQÀqÁrÈ1É2ÀvÁYÇ_Á_ÓEVÐ)WÐ^_Ô `Öa˜’ÒaÜ "§¡¨!¨C¨R¨C°°"°¨H©+×*;Ñ*;Ó*=¸tÀQÀqÁrÈ1É2ÀvÁYÇ_Á_ÓEVÐ)WÐ^_Ô `Öa˜’Òañð òð ˆC�N‰NÜ "§¡¨!¨C¨R¨C°±¨G©*×*:Ñ*:Ó*<¸dÀAÀaÁbÈ#È2È#ÀgÁJ×DTÑDTÓDVÐ)WÐ^_Ô `Öa˜’ÒaÜ "§¡¨!¨C¨R¨C°±¨G©*×*:Ñ*:Ó*<¸dÀAÀaÁbÈ#È2È#ÀgÁJ×DTÑDTÓDVÐ)WÐ^_Ô `Öa˜’Òañð òð Ð"Ø�J‰JØ—'‘'“)˜qŸw™w›y°UÀtÐSXÐ_`ð õ bð #ùò!  ùÒ"6ùÚùÒ"6ùò bùÚaùò bùÚas/   «	KÁ	KÁ	KÁ/	K"Å:	K'Ç	K,
È6	K1Ê	K6
c                ó®   — t        |«      }| j                  |«      }| j                  |«      }t        ||«      \  }}	|�|j	                  ||	|||¬«       yy)aª  Plot contour lines on a single plot.

        Args:
            lines (sequence of arrays): Contour line data as returned by
                :func:`~contourpy.ContourGenerator.lines`.
            line_type (LineType or str): Type of ``lines`` data as returned by
                :attr:`~contourpy.ContourGenerator.line_type`, or a string equivalent.
            ax (int or Bokeh Figure, optional): Which plot to use, default ``0``.
            color (str, optional): Color to plot lines. May be a string color or the letter ``"C"``
                followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the
                ``Category10`` palette. Default ``"C0"``.
            alpha (float, optional): Opacity to plot lines with, default ``1.0``.
            linewidth (float, optional): Width of lines, default ``1``.

        Note:
            Assumes all lines are open line strips not closed line loops.
        N)rZ   Ú
line_alpharS   )r   rN   rK   r   Úline)
r8   ÚlinesÚ	line_typerM   rI   rX   Ú	linewidthrA   rP   rQ   s
             rB   rr   zBokehRenderer.lines©   s^   € ô4 ! Ó+ˆ	Ø×Ñ˜rÓ"ˆØ×#Ñ# EÓ*ˆÜ  yÓ1‰ˆˆBØˆ>Ø�H‰H�R˜¨¸%ÈIˆHÕVð rD   c                ó   — t         j                  j                  |«      }|t         j                  j                  u ry| j	                  |«      }| j                  |«      }| j                  ||«      \  }}|j                  ||   ||   |d¬«       y)aÛ  Plot masked out grid points as circles on a single plot.

        Args:
            x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points.
            y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points.
            z (masked array of shape (ny, nx): z-values.
            ax (int or Bokeh Figure, optional): Which plot to use, default ``0``.
            color (str, optional): Circle color, default ``"black"``.
        Nr#   )r_   r`   )r.   ÚmaÚgetmaskÚnomaskrN   rK   ra   rg   )r8   r]   r^   ÚzrM   rI   ÚmaskrA   s           rB   rz   zBokehRenderer.maskÊ   s{   € ô" �u‰u�}‰}˜QÓˆØ”2—5‘5—<‘<ÑØØ×Ñ˜rÓ"ˆØ×#Ñ# EÓ*ˆØ×Ñ  1Ó%‰ˆˆ1Ø�
‰
�1�T‘7˜A˜d™G°¸Bˆ
Õ?rD   )Ú	webdriverc               óÀ   — |r| j                   D ]  }d|_        d|_        Œ | j                  rt	        | j
                  ||¬«       yt        | j
                  ||¬«       y)aÝ  Save plots to SVG or PNG file.

        Args:
            filename (str): Filename to save to.
            transparent (bool, optional): Whether background should be transparent, default
                ``False``.
            webdriver (WebDriver, optional): Selenium WebDriver instance to use to create the image.

                .. versionadded:: 1.1.1

        Warning:
            To output to SVG file, ``want_svg=True`` must have been passed to the constructor.
        N)Úfilenamer{   )r   Úbackground_fill_colorÚborder_fill_colorr!   r   r   r   )r8   r}   Útransparentr{   rA   s        rB   ÚsavezBokehRenderer.saveã   sS   € ñ( Ø—}‘}ò -�Ø,0�Ô)Ø(,�Õ%ð-ð �>Š>Ü�t—|‘|¨hÀ)ÖLä�t—|‘|¨hÀ)ÖLrD   c               ó€   — t        | j                  |¬«      }t        j                  «       }|j	                  |d«       |S )a  Save plots to an ``io.BytesIO`` buffer.

        Args:
            webdriver (WebDriver, optional): Selenium WebDriver instance to use to create the image.

                .. versionadded:: 1.1.1

        Return:
            BytesIO: PNG image buffer.
        )ÚdriverÚpng)r	   r   ÚioÚBytesIOr�   )r8   r{   ÚimageÚbuffers       rB   Úsave_to_bufferzBokehRenderer.save_to_buffer  s2   € ô & d§l¡l¸9ÔEˆÜ—‘“ˆØ�
‰
�6˜5Ô!ØˆrD   c                ó.   — t        | j                  «       y)z:Show plots in web browser, in usual Bokeh manner.
        N)r   r   )r8   s    rB   r   zBokehRenderer.show  s   € ô 	ˆT�\‰\ÕrD   c                óœ   — | j                  |«      }||_        d|j                  _        |�!| j                  |«      |j                  _        yy)aÌ  Set the title of a single plot.

        Args:
            title (str): Title text.
            ax (int or Bokeh Figure, optional): Which plot to set the title of, default ``0``.
            color (str, optional): Color to set title. May be a string color or the letter ``"C"``
                followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the
                ``Category10`` palette. Default ``None`` which is ``black``.
        ÚcenterN)rN   ÚtitleÚalignrK   Ú
text_color)r8   r�   rM   rI   rA   s        rB   r�   zBokehRenderer.title  sH   € ð ×Ñ˜rÓ"ˆØˆŒ	Ø"ˆ�	‰	ŒØÐØ#'×#6Ñ#6°uÓ#=ˆC�I‰IÕ ð rD   c                óê  — | j                  |«      }| j                  |«      }| j                  ||«      \  }}t        j                  |«      }|j
                  \  }	}
t        |dd¬«      }t        |	«      D ]D  }t        |
«      D ]4  }|j                  t        d	|||f   |||f   |||f   |› d�›dœ|¤Ž«       Œ6 ŒF |r¶t        |	dz
  «      D ]¤  }t        |
dz
  «      D ]‘  }t        j                  |||dz   …||dz   …f   «      }t        j                  |||dz   …||dz   …f   «      }t        j                  |||dz   …||dz   …f   «      }|j                  t        d	||||› d�›dœ|¤Ž«       Œ“ Œ¦ yy)
a­  Show ``z`` values on a single plot.

        Args:
            x (array-like of shape (ny, nx) or (nx,)): The x-coordinates of the grid points.
            y (array-like of shape (ny, nx) or (ny,)): The y-coordinates of the grid points.
            z (array-like of shape (ny, nx): z-values.
            ax (int or Bokeh Figure, optional): Which plot to use, default ``0``.
            color (str, optional): Color of added text. May be a string color or the letter ``"C"``
                followed by an integer in the range ``"C0"`` to ``"C9"`` to use a color from the
                ``Category10`` palette. Default ``"green"``.
            fmt (str, optional): Format to display z-values, default ``".1f"``.
            quad_as_tri (bool, optional): Whether to show z-values at the ``quad_as_tri`` centres
                of quads.

        Warning:
            ``quad_as_tri=True`` shows z-values for all quads, even if masked.
        rŒ   Úmiddle)r�   Ú
text_alignÚtext_baselineÚ )r]   r^   Útextr)   é   N© )rN   rK   ra   r.   r/   Úshaperc   r1   Ú
add_layoutr   Úmean)r8   r]   r^   ry   rM   rI   ÚfmtÚquad_as_trirA   ÚnyÚnxrk   ÚjÚiÚxxÚyyÚzzs                    rB   Úz_valueszBokehRenderer.z_values&  s¢  € ð6 ×Ñ˜rÓ"ˆØ×#Ñ# EÓ*ˆØ×Ñ  1Ó%‰ˆˆ1Ü�J‰J�q‹MˆØ—‘‰ˆˆBÜ °8È8ÔTˆÜ�r“ò 	_ˆAÜ˜2“Yò _�Ø—‘œuÐ] q¨¨A¨¡w°!°A°q°D±'À1ÀQÈÀTÁ7ÈCÈ5ÐPPÈ&À/Ñ]ÐV\Ñ]Õ^ñ_ð	_ñ Ü˜2˜a™4“[ò T�Ü˜r !™t›ò T�AÜŸ™  1 Q q¡S 5¨!¨A¨a©C¨% <¡Ó1�BÜŸ™  1 Q q¡S 5¨!¨A¨a©C¨% <¡Ó1�BÜŸ™  1 Q q¡S 5¨!¨A¨a©C¨% <¡Ó1�BØ—N‘N¤5Ð#R¨2°¸RÀÀÀP¸v¸JÑ#RÈ6Ñ#RÕSñ	TñTð rD   )r)   r)   )é	   r¥   TF)r9   r0   r*   r0   r:   ztuple[float, float]r;   r    r<   r    ÚreturnÚNone)rI   rH   r¦   rH   )rM   úfigure | intr¦   r   )r   ÚC0gffffffæ?)rV   r   rW   zFillType | strrM   r¨   rI   rH   rX   Úfloatr¦   r§   )r   Úblackgš™™™™™¹?Nr   )r]   r   r^   r   rM   r¨   rI   rH   rX   rª   rh   ú
str | Noneri   rª   r¦   r§   )r   r©   g      ð?r)   )rr   r   rs   zLineType | strrM   r¨   rI   rH   rX   rª   rt   rª   r¦   r§   )r   r«   )r]   r   r^   r   ry   z'ArrayLike | np.ma.MaskedArray[Any, Any]rM   r¨   rI   rH   r¦   r§   )F)r}   rH   r€   r    r{   úWebDriver | Noner¦   r§   )r{   r­   r¦   z
io.BytesIO)r¦   r§   )r   N)r�   rH   rM   r¨   rI   r¬   r¦   r§   )r   Úgreenz.1fF)r]   r   r^   r   ry   r   rM   r¨   rI   rH   r›   rH   rœ   r    r¦   r§   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__rC   rK   rN   rV   rn   rr   rz   r�   r‰   r   r�   r¤   r—   rD   rB   r   r      s®  … ñð  ÓØÓØÓØƒOð ØØ'-ØØðIàðIð ðIð %ð	Ið
 ðIð ðIð 
óIó:óð ØØð^àð^ð "ð^ð ð	^ð
 ð^ð ð^ð 
ó^ð@ ØØØ"&Ø#$ð1bàð1bð ð1bð ð	1bð
 ð1bð ð1bð  ð1bð !ð1bð 
ó1bðn ØØØðWàðWð "ðWð ð	Wð
 ðWð ðWð ðWð 
óWðL Øð@àð@ð ð@ð 3ð	@ð
 ð@ð ð@ð 
ó@ð8 "ðMð
 '+ñMàðMð ðMð
 $ðMð 
óMð< ?Cõ ó ô
>ð* ØØØ!ð*Tàð*Tð ð*Tð ð	*Tð
 ð*Tð ð*Tð ð*Tð ð*Tð 
ô*TrD   r   ),Ú
__future__r   r…   Útypingr   r   Úbokeh.ior   r   r   Úbokeh.io.exportr	   Úbokeh.layoutsr
   Úbokeh.models.annotations.labelsr   Úbokeh.palettesr   Úbokeh.plottingr   Únumpyr.   Ú	contourpyr   r   Úcontourpy.enum_utilr   r   Úcontourpy.util.bokeh_utilr   r   Úcontourpy.util.rendererr   Úbokeh.modelsr   r   Únumpy.typingr   Ú#selenium.webdriver.remote.webdriverr   Úcontourpy._contourpyr   r   r   r—   rD   rB   ú<module>rÅ      sT   ðÝ "ã 	ß %ç 1Ñ 1Ý 1Ý "Ý 1Ý %Ý !Û ç (ß :ß EÝ ,áÝ%Ý&Ý&Ý=ç;ôtT�Hõ tTrD   