Ë
    ^ãjR6  ã                  ó.  — 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 er4d 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'm(Z( d dl)m*Z*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)Úas_fill_typeÚas_line_type)Úfilled_to_bokehÚlines_to_bokeh)ÚRenderer)ÚOutputBackendType)ÚGridPlot)ÚPalette)ÚMultiLineArgs)Ú	ArrayLike)Ú	WebDriver)ÚFillTypeÚLineType)Ú
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),ÚBokehRenderera  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:`~.BokehRenderer`, unlike :class:`~.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              ú_/var/www/html/metafoliadorv2/venv/lib/python3.12/site-packages/contourpy/util/bokeh_renderer.pyÚ__init__zBokehRenderer.__init__3   s×   € ð "ˆŒÜ" 2™ˆŒàœŸ™ G´3Ô7Ñ7ˆ
à˜‘;ˆØˆŒØ.2¯nªn¡UÀ(ˆÜ�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Ústrr2   r!   )r:   ÚcolorÚindexs      rD   Ú_convert_colorzBokehRenderer._convert_colorP   s8   € Ü�eœSÔ! e¨A¡h°#¢oÜ˜˜a˜b˜	“NˆEØ—M‘M %Ñ(ˆEØˆrF   c                óD   — t        |t        «      r| j                  |   }|S )N)rI   r2   r   )r:   Úaxs     rD   Ú_get_figurezBokehRenderer._get_figureV   s   € Ü�bœ#ÔØ—‘˜rÑ"ˆBØˆ	rF   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
                :meth:`~.ContourGenerator.filled`.
            fill_type (FillType or str): Type of :meth:`~.ContourGenerator.filled` data as returned
                by :attr:`~.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ÚysrK   Ú
fill_alphaÚ
line_widthN)r   rP   rM   r   ÚlenÚmulti_polygons)	r:   ÚfilledÚ	fill_typerO   rK   ÚalpharC   rR   rS   s	            rD   rX   zBokehRenderer.filled[   sl   € ô* ! Ó+ˆ	Ø×Ñ˜rÓ"ˆØ×#Ñ# EÓ*ˆÜ  ¨Ó3‰ˆˆBÜˆr‹7�QŠ;Ø×Ñ 2 $¨B¨4°uÈÐ[\ÐÕ]ð rF   Nc                óH  — | j                  |«      }| j                  ||«      \  }}t        |«      t        |j                  «      z   }	t        |«      t        |j                  «      z   }
||dœ} |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        t        j                  |dd…dd…f   j                  «       ||dd…dd…f   j                  «       fd¬«      «      t        t        j                  |dd…dd…f   j                  «       ||dd…dd…f   j                  «       fd¬«      «      fi |¤Ž  |j                  t        t        j                  |dd…dd…f   j                  «       ||dd…dd…f   j                  «       fd¬«      «      t        t        j                  |dd…dd…f   j                  «       ||dd…dd…f   j                  «       fd¬«      «      fi |¤Ž |�5|j                  |j                  «       |j                  «       |d|dd	¬
«       yy)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_colorrZ   r   g      Ð?Néÿÿÿÿr+   )r9   Úcircleé   )ÚxÚyÚ
fill_colorr\   rZ   ÚmarkerÚsize)	rP   Ú_grid_as_2dÚlistÚTÚ
multi_lineÚravelr0   ÚstackÚscatter)r:   r`   ra   rO   rK   rZ   Úpoint_colorÚquad_as_tri_alpharC   rR   rS   ÚkwargsÚxmidÚymids                 rD   ÚgridzBokehRenderer.gridw   s¾  € ð: ×Ñ˜rÓ"ˆØ×Ñ  1Ó%‰ˆˆ1Ü�!‹W”t˜AŸC™C“yÑ ˆÜ�!‹W”t˜AŸC™C“yÑ ˆØ/4¸uÑ EˆØˆ�‰�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Ü”R—X‘X˜q  "  c r c ™{×0Ñ0Ó2°D¸!¸A¹BÀÁ¸F¹)¿/¹/Ó:KÐLÐSTÔUÓVÜ”R—X‘X˜q  "  c r c ™{×0Ñ0Ó2°D¸!¸A¹BÀÁ¸F¹)¿/¹/Ó:KÐLÐSTÔUÓVñð òð ˆC�N‰NÜ”R—X‘X˜q  "  a¡b ™z×/Ñ/Ó1°4¸¸1¹2¸sÀ¸s¸7¹×9IÑ9IÓ9KÐLÐSTÔUÓVÜ”R—X‘X˜q  "  a¡b ™z×/Ñ/Ó1°4¸¸1¹2¸sÀ¸s¸7¹×9IÑ9IÓ9KÐLÐSTÔUÓVñð òð Ð"Ø�K‰KØ—'‘'“)˜qŸw™w›y°UÀtÐSXØ að õ )ð #rF   c                ó¶   — t        |«      }| j                  |«      }| j                  |«      }t        ||«      \  }}	|�|	€J ‚|j	                  ||	|||¬«       yy)a¯  Plot contour lines on a single plot.

        Args:
            lines (sequence of arrays): Contour line data as returned by
                :meth:`~.ContourGenerator.lines`.
            line_type (LineType or str): Type of :meth:`~.ContourGenerator.lines` data as returned
                by :attr:`~.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)r\   Ú
line_alpharU   )r   rP   rM   r   Úline)
r:   ÚlinesÚ	line_typerO   rK   rZ   Ú	linewidthrC   rR   rS   s
             rD   ru   zBokehRenderer.lines«   sh   € ô4 ! Ó+ˆ	Ø×Ñ˜rÓ"ˆØ×#Ñ# EÓ*ˆÜ  yÓ1‰ˆˆBØˆ>Ø�>Ð!�>Ø�H‰H�R˜¨¸%ÈIˆHÕVð rF   c                ó"  — t         j                  j                  |«      }|t         j                  j                  u ry| j	                  |«      }| j                  |«      }| j                  ||«      \  }}|j                  ||   ||   |d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%   )rb   rc   rd   )r0   ÚmaÚgetmaskÚnomaskrP   rM   re   rk   )r:   r`   ra   ÚzrO   rK   ÚmaskrC   s           rD   r}   zBokehRenderer.maskÍ   s}   € ô" �u‰u�}‰}˜QÓˆØ”2—5‘5—<‘<ÑØØ×Ñ˜rÓ"ˆØ×#Ñ# EÓ*ˆØ×Ñ  1Ó%‰ˆˆ1Ø�‰�A�d‘G˜Q˜t™W°¸xÈbˆÕQrF   )Ú	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   )r:   r€   Útransparentr~   rC   s        rD   ÚsavezBokehRenderer.saveæ   sS   € ñ( Ø—}‘}ò -�Ø,0�Ô)Ø(,�Õ%ð-ð �>Š>Ü�t—|‘|¨hÀ)ÖLä�t—|‘|¨hÀ)ÖLrF   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„   )r:   r~   ÚimageÚbuffers       rD   Úsave_to_bufferzBokehRenderer.save_to_buffer  s2   € ô & d§l¡l¸9ÔEˆÜ—‘“ˆØ�
‰
�6˜5Ô!ØˆrF   c                ó.   — t        | j                  «       y)z:Show plots in web browser, in usual Bokeh manner.
        N)r   r    )r:   s    rD   r   zBokehRenderer.show  s   € ô 	ˆT�\‰\ÕrF   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)rP   ÚtitleÚalignrM   Ú
text_color)r:   r�   rO   rK   rC   s        rD   r�   zBokehRenderer.title  sH   € ð ×Ñ˜rÓ"ˆØˆŒ	Ø"ˆ�	‰	ŒØÐØ#'×#6Ñ#6°uÓ#=ˆC�I‰IÕ ð rF   c                óÞ  — | j                  |«      }| j                  |«      }| j                  ||«      \  }}t        j                  |«      }|j
                  \  }	}
|dddœ}t        |	«      D ]F  }t        |
«      D ]6  }t        d	|||f   |||f   |||f   |› d�›dœ|¤Ž}|j                  |«       Œ8 ŒH |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`   ra   Útextr+   é   N© )
rP   rM   re   r0   r1   Úshaper3   r   Ú
add_layoutÚmean)r:   r`   ra   r|   rO   rK   ÚfmtÚquad_as_trirC   ÚnyÚnxrn   ÚjÚiÚlabelÚxxÚyyÚzzs                     rD   Úz_valueszBokehRenderer.z_values)  s   € ð6 ×Ñ˜rÓ"ˆØ×#Ñ# EÓ*ˆØ×Ñ  1Ó%‰ˆˆ1Ü�J‰J�q‹MˆØ—‘‰ˆˆBØ %°XÐPXÑYˆÜ�r“ò 	&ˆAÜ˜2“Yò &�ÜÐV  ! Q $¡¨1¨Q°¨T©7¸A¸aÀ¸d¹GÀSÀEÈÀ6¸?ÑVÈvÑV�Ø—‘˜uÕ%ñ&ð	&ñ Ü˜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ð rF   )r+   r+   )é	   r©   TF)r;   r2   r,   r2   r<   ztuple[float, float]r=   r"   r>   r"   ÚreturnÚNone)rK   rJ   rª   rJ   )rO   úfigure | intrª   r   )r   ÚC0gffffffæ?)rX   r   rY   zFillType | strrO   r¬   rK   rJ   rZ   Úfloatrª   r«   )r   Úblackgš™™™™™¹?Nr   )r`   r   ra   r   rO   r¬   rK   rJ   rZ   r®   rl   ú
str | Nonerm   r®   rª   r«   )r   r­   g      ð?r+   )ru   r   rv   zLineType | strrO   r¬   rK   rJ   rZ   r®   rw   r®   rª   r«   )r   r¯   )r`   r   ra   r   r|   z'ArrayLike | np.ma.MaskedArray[Any, Any]rO   r¬   rK   rJ   rª   r«   )F)r€   rJ   rƒ   r"   r~   úWebDriver | Nonerª   r«   )r~   r±   rª   z
io.BytesIO)rª   r«   )r   N)r�   rJ   rO   r¬   rK   r°   rª   r«   )r   Úgreenz.1fF)r`   r   ra   r   r|   r   rO   r¬   rK   rJ   rž   rJ   rŸ   r"   rª   r«   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__rE   rM   rP   rX   rq   ru   r}   r„   rŒ   r   r�   r¨   rš   rF   rD   r   r      s¥  … ñð ÓØÓØÓØƒOð ØØ'-ØØðIàðIð ðIð %ð	Ið
 ðIð ðIð 
óIó:óð ØØð^àð^ð "ð^ð ð	^ð
 ð^ð ð^ð 
ó^ð@ ØØØ"&Ø#$ð2)àð2)ð ð2)ð ð	2)ð
 ð2)ð ð2)ð  ð2)ð !ð2)ð 
ó2)ðp ØØØð Wàð Wð "ð Wð ð	 Wð
 ð Wð ð Wð ð Wð 
ó WðN ØðRàðRð ðRð 3ð	Rð
 ðRð ðRð 
óRð8 "ðMð
 '+ñMàðMð ðMð
 $ðMð 
óMð< ?Cõ ó ô
>ð* ØØØ!ð+Tàð+Tð ð+Tð ð	+Tð
 ð+Tð ð+Tð ð+Tð ð+Tð 
ô+TrF   r   )0Ú
__future__r   rˆ   Útypingr   r   Úbokeh.ior   r   r   Úbokeh.io.exportr	   Úbokeh.layoutsr
   Úbokeh.models.annotations.labelsr   Úbokeh.palettesr   Úbokeh.plottingr   Únumpyr0   Úcontourpy.enum_utilr   r   Úcontourpy.util.bokeh_utilr   r   Úcontourpy.util.rendererr   Úbokeh.core.enumsr   Úbokeh.modelsr   r   Úbokeh.plotting.glyph_apir   Únumpy.typingr   Ú#selenium.webdriver.remote.webdriverr   Ú	contourpyr   r   Úcontourpy._contourpyr   r   r   rš   rF   rD   ú<module>rË      sZ   ðÝ "ã 	ß %ç 1Ñ 1Ý 1Ý "Ý 1Ý %Ý !Û ç :ß EÝ ,áÝ2Ý%Ý&Ý6Ý&Ý=ç,ß;ôvT�Hõ vTrF   