
    h6                    ,   S SK Jr  S SKrS SKJrJr  S SKJrJrJ	r	  S SK
Jr  S SKJr  S SKJr  S SKJr  S S	KJr  S SKrS S
KJrJr  S SKJrJr  S SKJr  \(       a.  S SKJr  S SK J!r!  S SKJ"r"  S SK#J$r$  S SK%J&r&  S SK'J(r(J)r)  S SK*J+r+J,r,   " S S\5      r-g)    )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)	ArrayLike)	WebDriver)FillTypeLineType)
FillReturn
LineReturnc                     \ rS rSr% SrS\S'   S\S'   S\S'   S	\S
'        S           SS jjrSS jrSS jr   S           SS jjr	     S                S!S jjr
    S"             S#S jjr  S$           S%S jjr S&SS.       S'S jjjrSS.S(S jjrS)S jrS*S+S jjr    S,               S-S jjrSrg).BokehRenderer   a  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                   XPl         [        S   U l        S[        R                  " U[
        S9-  nX-  n/ U l        U R                   (       a  SOSn[        U5       Hj  n	[        US9n
SU
R                  l
        SU
R                  l
        U R                  R                  U
5        U(       a  MR  S U
l        SU
R                  l
        Ml     [        U R                  US US   U-  US	   U-  S
9U l        g )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              O/var/www/html/env/lib/python3.13/site-packages/contourpy/util/bokeh_renderer.py__init__BokehRenderer.__init__2   s     ""2G377
;.2nnU(xA0C %CII %CIIMM  %:)-&#(  !  MMQ-5(A%1GI    c                |    [        U[        5      (       a&  US   S:X  a  [        USS  5      nU R                  U   nU$ )Nr   Cr+   )
isinstancestrr2   r!   )r:   colorindexs      rD   _convert_colorBokehRenderer._convert_colorO   s;    eS!!eAh#oab	NEMM%(ErG   c                N    [        U[        5      (       a  U R                  U   nU$ )N)rJ   r2   r   )r:   axs     rD   _get_figureBokehRenderer._get_figureU   s"    b#r"B	rG   c                    [        U5      nU R                  U5      nU R                  U5      n[        X5      u  px[	        U5      S:  a  UR                  U/U/XESS9  gg)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ysrL   
fill_alpha
line_widthN)r   rR   rN   r   lenmulti_polygons)	r:   filled	fill_typerQ   rL   alpharC   rU   rV   s	            rD   r[   BokehRenderer.filledZ   sf    * !+	r"##E* 3r7Q;2$B4u[\] rG   Nc                &   U R                  U5      nU R                  X5      u  p[        U5      [        UR                  5      -   n	[        U5      [        UR                  5      -   n
XES.nUR                  " X40 UD6  US:  Ga  SUSS2SS24   USS2SS24   -   USS2SS24   -   USS2SS24   -   -  R                  5       nSUSS2SS24   USS2SS24   -   USS2SS24   -   USS2SS24   -   -  R                  5       nUR                  " [        [        R                  " USS2SS24   R                  5       XSS2SS24   R                  5       4SS95      [        [        R                  " USS2SS24   R                  5       XSS2SS24   R                  5       4SS95      40 UD6  UR                  " [        [        R                  " USS2SS24   R                  5       XSS2SS24   R                  5       4SS95      [        [        R                  " USS2SS24   R                  5       XSS2SS24   R                  5       4SS95      40 UD6  Ub2  UR                  UR                  5       UR                  5       USUSS	S
9  gg)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_colorr]   r   g      ?Nr+   )r9   circle   )xy
fill_colorr`   r]   markersize)	rR   _grid_as_2dlistT
multi_lineravelr0   stackscatter)r:   rd   re   rQ   rL   r]   point_colorquad_as_tri_alpharC   rU   rV   kwargsxmidymids                 rD   gridBokehRenderer.gridv   s   : r"%!WtACCy !WtACCy  %6r((q !CRC"H+!"crc'
2QssABwZ?!ABF)KLSSUD!CRC"H+!"crc'
2QssABwZ?!ABF)KLSSUDNNRXXq"crc{002DABF)//:KLSTUVRXXq"crc{002DABF)//:KLSTUV  NNRXXq"abz//1412ss79I9I9KLSTUVRXXq"abz//1412ss79I9I9KLSTUV  "KK'')qwwyUtSXa  ) #rG   c                    [        U5      nU R                  U5      nU R                  U5      n[        X5      u  pUb  U	c   eUR	                  XXEUS9  gg)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_alpharX   )r   rR   rN   r   line)
r:   lines	line_typerQ   rL   r]   	linewidthrC   rU   rV   s
             rD   rz   BokehRenderer.lines   s`    4 !+	r"##E*1>>!>HHRIHV rG   c                   [         R                  R                  U5      nU[         R                  R                  L a  gU R	                  U5      nU R                  U5      nU R                  X5      u  pUR                  X   X&   USSS9  g)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"``.
Nrb   r%   )rf   rg   rh   )r0   magetmasknomaskrR   rN   ri   ro   )r:   rd   re   zrQ   rL   maskrC   s           rD   r   BokehRenderer.mask   su    " uu}}Q255<<r"##E*%AGQWxbQrG   )	webdriverc                   U(       a!  U R                    H  nSUl        SUl        M     U R                  (       a  [	        U R
                  XS9  g[        U R
                  XS9  g)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   saveBokehRenderer.save   sJ    ( }},0)(,% % >>t||hLt||hLrG   c               |    [        U R                  US9n[        R                  " 5       nUR	                  US5        U$ )zSave 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_bufferBokehRenderer.save_to_buffer  s2     &dll9E

65!rG   c                .    [        U R                  5        g)z:Show plots in web browser, in usual Bokeh manner.
        N)r   r    )r:   s    rD   r   BokehRenderer.show  s     	T\\rG   c                    U R                  U5      nXl        SUR                  l        Ub!  U R                  U5      UR                  l        gg)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)rR   titlealignrN   
text_color)r:   r   rQ   rL   rC   s        rD   r   BokehRenderer.title  sF     r"	"		#'#6#6u#=CII  rG   c                   U R                  U5      nU R                  U5      nU R                  X5      u  p[        R                  " U5      nUR
                  u  pUSSS.n[        U	5       HD  n[        U
5       H2  n[        SXU4   X,U4   X<U4   U  S.UD6nUR                  U5        M4     MF     U(       a  [        U	S-
  5       H  n[        U
S-
  5       H  n[        R                  " XUS-   2XS-   24   5      n[        R                  " X,US-   2XS-   24   5      n[        R                  " X<US-   2XS-   24   5      nUR                  [        SUUUU  S.UD65        M     M     gg)	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)rd   re   textr+      N )
rR   rN   ri   r0   r1   shaper3   r   
add_layoutmean)r:   rd   re   r   rQ   rL   fmtquad_as_trirC   nynxrr   jilabelxxyyzzs                     rD   z_valuesBokehRenderer.z_values(  sh   6 r"##E*%JJqM %XPXYrA2YVQ$1T7AdGSE?VvVu%   2a4[r!tAQqS5!aC%<1BQqS5!aC%<1BQqS5!aC%<1BNN5#R2RJ#R6#RS	 % ! rG   )r   r    r!   r#   )r+   r+   )	   r   TF)r;   r2   r,   r2   r<   ztuple[float, float]r=   r"   r>   r"   returnNone)rL   rK   r   rK   )rQ   figure | intr   r   )r   C0gffffff?)r[   r   r\   zFillType | strrQ   r   rL   rK   r]   floatr   r   )r   blackg?Nr   )rd   r   re   r   rQ   r   rL   rK   r]   r   rp   
str | Nonerq   r   r   r   )r   r   g      ?r+   )rz   r   r{   zLineType | strrQ   r   rL   rK   r]   r   r|   r   r   r   )r   r   )rd   r   re   r   r   z'ArrayLike | np.ma.MaskedArray[Any, Any]rQ   r   rL   rK   r   r   )F)r   rK   r   r"   r   WebDriver | Noner   r   )r   r   r   z
io.BytesIO)r   r   )r   N)r   rK   rQ   r   rL   r   r   r   )r   greenz.1fF)rd   r   re   r   r   r   rQ   r   rL   rK   r   rK   r   r"   r   r   )__name__
__module____qualname____firstlineno____doc____annotations__rE   rN   rR   r[   ru   rz   r   r   r   r   r   r   __static_attributes__r   rG   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 +TrG   r   ).
__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   numpy.typingr   #selenium.webdriver.remote.webdriverr   	contourpyr   r   contourpy._contourpyr   r   r   r   rG   rD   <module>r      sW    " 	 % 1 1 1 " 1 % !  : E ,2%&&=,;vTH vTrG   