§
    …ÛgÉ5  ã                  ó  — 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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' d dl(m)Z)m*Z*  G d„ de¦  «        Z+dS )é    )Ú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)ÚGridPlot)ÚPalette)Ú	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	<   	 	 	 	 	 dMdNd„ZdOd„ZdPd„Z	 	 	 dQdRd(„Z	 	 	 	 	 dSdTd2„Z		 	 	 	 dUdVd9„Z
	 	 dWdXd<„Z	 dYd+d=œdZdB„Zd+d=œd[dD„Zd\dE„Zd]d^dG„Z	 	 	 	 d_d`dL„Zd+S )aÚ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_svgé   ©é	   r$   TFÚnrowsÚintÚncolsÚfigsizeútuple[float, float]Ú
show_frameÚwant_svgÚreturnÚNonec                óÔ  — || _         t          d         | _        dt          j        |t
          ¬¦  «        z  }||z  }g | _        | j         rdnd}t          |¦  «        D ]Y}	t          |¬¦  «        }
d|
j	        _
        d|
j        _
        | j                             |
¦  «         |sd |
_        d|
j        _
        ŒZt          | j        |d |d         |z  |d	         |z  ¬
¦  «        | _        d S )Né
   éd   )ÚdtypeÚsvgÚcanvas)Úoutput_backendFr   r"   )r'   Útoolbar_locationÚwidthÚheight)r!   r   r   ÚnpÚasarrayr&   r   Úranger   ÚxgridÚvisibleÚygridÚappendÚoutline_line_colorÚaxisr
   r   )Úselfr%   r'   r(   r*   r+   Ú
total_sizeÚnfiguresÚbackendÚ_Úfigs              úS/granary/edev/quantum/lib/python3.11/site-packages/contourpy/util/bokeh_renderer.pyÚ__init__zBokehRenderer.__init__1   sö   € ð "ˆŒÝ" 2œˆŒà�œ Gµ3Ð7Ñ7Ô7Ñ7ˆ
à˜‘;ˆØˆŒØœ>Ð7�%�%¨xˆÝ�x‘”ð 	)ð 	)ˆAÝ¨Ð0Ñ0Ô0ˆCØ %ˆCŒIÔØ %ˆCŒIÔØŒM× Ò  Ñ%Ô%Ð%Øð )Ø)-�Ô&Ø#(�”Ô øåØŒM ¸Ø˜Q”- 5Ñ(°¸A´À%Ñ1GðIñ Iô IˆŒˆˆó    ÚcolorÚstrc                ó�   — t          |t          ¦  «        r0|d         dk    r$t          |dd …         ¦  «        }| j        |         }|S )Nr   ÚCr"   )Ú
isinstancerK   r&   r   )rA   rJ   Úindexs      rG   Ú_convert_colorzBokehRenderer._convert_colorN   sD   € Ý�e�SÑ!Ô!ð 	) e¨A¤h°#¢o oÝ˜˜a˜b˜bœ	‘N”NˆEØ”M %Ô(ˆEØˆrI   Úaxúfigure | intr   c                óJ   — t          |t          ¦  «        r| j        |         }|S )N)rN   r&   r   )rA   rQ   s     rG   Ú_get_figurezBokehRenderer._get_figureT   s%   € Ý�b�#ÑÔð 	#Ø”˜rÔ"ˆBØˆ	rI   r   ÚC0çffffffæ?Úfilledr   Ú	fill_typeúFillType | strÚalphaÚfloatc                ó   — t          |¦  «        }|                      |¦  «        }|                      |¦  «        }t          ||¦  «        \  }}t	          |¦  «        dk    r|                     |g|g||d¬¦  «         dS dS )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ÚysrJ   Ú
fill_alphaÚ
line_widthN)r   rT   rP   r   ÚlenÚmulti_polygons)	rA   rW   rX   rQ   rJ   rZ   rF   r]   r^   s	            rG   rW   zBokehRenderer.filledY   sŠ   € õ* ! Ñ+Ô+ˆ	Ø×Ò˜rÑ"Ô"ˆØ×#Ò# EÑ*Ô*ˆÝ  ¨Ñ3Ô3‰ˆˆBÝˆr‰7Œ7�QŠ;ˆ;Ø×Ò 2 $¨B¨4°uÈÐ[\ÐÑ]Ô]Ð]Ð]Ð]ð ˆ;rI   Úblackçš™™™™™¹?NÚxr   ÚyÚpoint_colorú
str | NoneÚquad_as_tri_alphac                ó,  — |                       |¦  «        }|                      ||¦  «        \  }}t          |¦  «        t          |j        ¦  «        z   }	t          |¦  «        t          |j        ¦  «        z   }
||dœ} |j        |	|
fi |¤Ž |dk    �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                       ¦   «         }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        t          t          j        |dd…dd…f                              ¦   «         ||dd…dd…f                              ¦   «         fd¬¦  «        ¦  «        t          t          j        |dd…dd…f                              ¦   «         ||dd…dd…f                              ¦   «         fd¬¦  «        ¦  «        fi |¤Ž  |j        t          t          j        |dd…dd…f                              ¦   «         ||dd…dd…f                              ¦   «         fd¬¦  «        ¦  «        t          t          j        |dd…dd…f                              ¦   «         ||dd…dd…f                              ¦   «         fd¬¦  «        ¦  «        fi |¤Ž |�B|                     |                     ¦   «         |                     ¦   «         |d|dd	¬
¦  «         dS dS )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"   )r@   Úcircleé   )re   rf   Ú
fill_colorrk   rZ   ÚmarkerÚsize)	rT   Ú_grid_as_2dÚlistÚTÚ
multi_lineÚravelr8   ÚstackÚscatter)rA   re   rf   rQ   rJ   rZ   rg   ri   rF   r]   r^   ÚkwargsÚxmidÚymids                 rG   ÚgridzBokehRenderer.gridu   sd  € ð: ×Ò˜rÑ"Ô"ˆØ×Ò  1Ñ%Ô%‰ˆˆ1Ý�!‰WŒW•t˜AœC‘y”yÑ ˆÝ�!‰WŒW•t˜AœC‘y”yÑ ˆØ %°Ð6Ð6ˆØˆŒ�r˜2Ð(Ð( Ð(Ð(Ð(Ø˜qÒ Ñ à˜!˜C˜R˜C  " ˜Hœ+¨¨!¨"¨"¨c¨r¨c¨'¬
Ñ2°Q°s¸°s¸A¸B¸B°w´ZÑ?À!ÀAÀBÀBÈÈÈÀFÄ)ÑKÑL×SÒSÑUÔUˆDØ˜!˜C˜R˜C  " ˜Hœ+¨¨!¨"¨"¨c¨r¨c¨'¬
Ñ2°Q°s¸°s¸A¸B¸B°w´ZÑ?À!ÀAÀBÀBÈÈÈÀFÄ)ÑKÑL×SÒSÑUÔUˆDØˆCŒNÝ•R”X˜q  "  c r c œ{×0Ò0Ñ2Ô2°D¸!¸A¸B¸BÀÀÀ¸F¼)¿/º/Ñ:KÔ:KÐLÐSTÐUÑUÔUÑVÔVÝ•R”X˜q  "  c r c œ{×0Ò0Ñ2Ô2°D¸!¸A¸B¸BÀÀÀ¸F¼)¿/º/Ñ:KÔ:KÐLÐSTÐUÑUÔUÑVÔVðð ð ðð ð ð ˆCŒNÝ•R”X˜q  "  a b b œz×/Ò/Ñ1Ô1°4¸¸1¸2¸2¸sÀ¸s¸7¼×9IÒ9IÑ9KÔ9KÐLÐSTÐUÑUÔUÑVÔVÝ•R”X˜q  "  a b b œz×/Ò/Ñ1Ô1°4¸¸1¸2¸2¸sÀ¸s¸7¼×9IÒ9IÑ9KÔ9KÐLÐSTÐUÑUÔUÑVÔVðð ð ðð ð ð Ð"Ø�KŠKØ—'’'‘)”)˜qŸwšw™yœy°UÀtÐSXØ að ñ )ô )ð )ð )ð )ð #Ð"rI   ç      ð?Úlinesr   Ú	line_typeúLineType | strÚ	linewidthc                óÚ   — t          |¦  «        }|                      |¦  «        }|                      |¦  «        }t          ||¦  «        \  }}	|�|                     ||	|||¬¦  «         dS dS )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)rk   Ú
line_alphar`   )r   rT   rP   r   Úline)
rA   r~   r   rQ   rJ   rZ   r�   rF   r]   r^   s
             rG   r~   zBokehRenderer.lines©   sx   € õ4 ! Ñ+Ô+ˆ	Ø×Ò˜rÑ"Ô"ˆØ×#Ò# EÑ*Ô*ˆÝ  yÑ1Ô1‰ˆˆBØˆ>Ø�HŠH�R˜¨¸%ÈIˆHÑVÔVÐVÐVÐVð ˆ>rI   Úzú'ArrayLike | np.ma.MaskedArray[Any, Any]c                ó@  — t           j                             |¦  «        }|t           j        j        u rdS |                      |¦  «        }|                      |¦  «        }|                      ||¦  «        \  }}|                     ||         ||         |dd¬¦  «         dS )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"``.
        Nrm   r/   )ro   rp   rq   )r8   ÚmaÚgetmaskÚnomaskrT   rP   rr   rx   )rA   re   rf   r…   rQ   rJ   ÚmaskrF   s           rG   r‹   zBokehRenderer.maskÊ   s”   € õ" Œu�}Š}˜QÑÔˆØ•2”5”<ÐÐØˆFØ×Ò˜rÑ"Ô"ˆØ×#Ò# EÑ*Ô*ˆØ×Ò  1Ñ%Ô%‰ˆˆ1Ø�Š�A�d”G˜Q˜tœW°¸xÈbˆÑQÔQÐQÐQÐQrI   )Ú	webdriverÚfilenameÚtransparentrŒ   úWebDriver | Nonec               ó¨   — |r| j         D ]}d|_        d|_        Œ| j        rt	          | j        ||¬¦  «         dS t          | j        ||¬¦  «         dS )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)r�   rŒ   )r   Úbackground_fill_colorÚborder_fill_colorr!   r   r   r   )rA   r�   rŽ   rŒ   rF   s        rG   ÚsavezBokehRenderer.saveã   su   € ð( ð 	-Ø”}ð -ð -�Ø,0�Ô)Ø(,�Ô%Ð%àŒ>ð 	MÝ�t”|¨hÀ)ÐLÑLÔLÐLÐLÐLå�t”|¨hÀ)ÐLÑLÔLÐLÐLÐLrI   ú
io.BytesIOc               ó„   — t          | j        |¬¦  «        }t          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“   )rA   rŒ   ÚimageÚbuffers       rG   Úsave_to_bufferzBokehRenderer.save_to_buffer  s<   € õ & d¤l¸9ÐEÑEÔEˆÝ”‘”ˆØ�
Š
�6˜5Ñ!Ô!Ð!ØˆrI   c                ó.   — t          | j        ¦  «         dS )z:Show plots in web browser, in usual Bokeh manner.
        N)r   r   )rA   s    rG   r   zBokehRenderer.show  s   € õ 	ˆTŒ\ÑÔÐÐÐrI   Útitlec                óœ   — |                       |¦  «        }||_        d|j        _        |�!|                      |¦  «        |j        _        dS dS )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)rT   rž   ÚalignrP   Ú
text_color)rA   rž   rQ   rJ   rF   s        rG   rž   zBokehRenderer.title  sS   € ð ×Ò˜rÑ"Ô"ˆØˆŒ	Ø"ˆŒ	ŒØÐØ#'×#6Ò#6°uÑ#=Ô#=ˆCŒIÔ Ð Ð ð ÐrI   Úgreenú.1fÚfmtÚquad_as_tric                ó$  — |                       |¦  «        }|                      |¦  «        }|                      ||¦  «        \  }}t          j        |¦  «        }|j        \  }	}
|dddœ}t          |	¦  «        D ]R}t          |
¦  «        D ]@}|                     t          d|||f         |||f         |||f         |› ›dœ|¤Ž¦  «         ŒAŒS|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         ¦  «        }|                     t          d||||› ›dœ|¤Ž¦  «         Œ›Œ°dS dS )	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)re   rf   Útextr"   é   N© )
rT   rP   rr   r8   r9   Úshaper:   Ú
add_layoutr   Úmean)rA   re   rf   r…   rQ   rJ   r¥   r¦   rF   ÚnyÚnxry   ÚjÚiÚxxÚyyÚzzs                    rG   Úz_valueszBokehRenderer.z_values&  sð  € ð6 ×Ò˜rÑ"Ô"ˆØ×#Ò# EÑ*Ô*ˆØ×Ò  1Ñ%Ô%‰ˆˆ1ÝŒJ�q‰MŒMˆØ”‰ˆˆBØ %°XÐPXÐYÐYˆÝ�r‘”ð 	_ð 	_ˆAÝ˜2‘Y”Yð _ð _�Ø—’�uÐ] q¨¨A¨¤w°!°A°q°D´'À1ÀQÈÀTÄ7ÈCÐ@RÐ@RÐ]Ð]ÐV\Ð]Ð]Ñ^Ô^Ð^Ð^ð_àð 	TÝ˜2˜a™4‘[”[ð Tð T�Ý˜r !™t™œð Tð T�AÝœ  1 Q q¡S 5¨!¨A¨a©C¨% <¤Ñ1Ô1�BÝœ  1 Q q¡S 5¨!¨A¨a©C¨% <¤Ñ1Ô1�BÝœ  1 Q q¡S 5¨!¨A¨a©C¨% <¤Ñ1Ô1�BØ—N’N¥5Ð#R¨2°¸RÀ¸-¸-Ð#RÐ#RÈ6Ð#RÐ#RÑSÔSÐSÐSð	Tð	Tð 	TðTð TrI   )r"   r"   r#   TF)r%   r&   r'   r&   r(   r)   r*   r    r+   r    r,   r-   )rJ   rK   r,   rK   )rQ   rR   r,   r   )r   rU   rV   )rW   r   rX   rY   rQ   rR   rJ   rK   rZ   r[   r,   r-   )r   rc   rd   Nr   )re   r   rf   r   rQ   rR   rJ   rK   rZ   r[   rg   rh   ri   r[   r,   r-   )r   rU   r}   r"   )r~   r   r   r€   rQ   rR   rJ   rK   rZ   r[   r�   r[   r,   r-   )r   rc   )re   r   rf   r   r…   r†   rQ   rR   rJ   rK   r,   r-   )F)r�   rK   rŽ   r    rŒ   r�   r,   r-   )rŒ   r�   r,   r”   )r,   r-   )r   N)rž   rK   rQ   rR   rJ   rh   r,   r-   )r   r£   r¤   F)re   r   rf   r   r…   r   rQ   rR   rJ   rK   r¥   rK   r¦   r    r,   r-   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__rH   rP   rT   rW   r|   r~   r‹   r“   rœ   r   rž   r¸   r­   rI   rG   r   r      s  € € € € € € ðð ð ÐÐÑØÐÐÑØÐÐÑØ€O€O�Oð ØØ'-ØØðIð Ið Ið Ið Ið:ð ð ð ðð ð ð ð ØØð^ð ^ð ^ð ^ð ^ð@ ØØØ"&Ø#$ð2)ð 2)ð 2)ð 2)ð 2)ðp ØØØðWð Wð Wð Wð WðL ØðRð Rð Rð Rð Rð8 "ðMð
 '+ðMð Mð Mð Mð Mð Mð< ?Cð ð ð ð ð ð ð ð ð ð ð
>ð >ð >ð >ð >ð* ØØØ!ð*Tð *Tð *Tð *Tð *Tð *Tð *TrI   r   ),Ú
__future__r   r˜   Útypingr   r   Úbokeh.ior   r   r   Úbokeh.io.exportr	   Úbokeh.layoutsr
   Úbokeh.models.annotations.labelsr   Úbokeh.palettesr   Úbokeh.plottingr   Únumpyr8   Úcontourpy.enum_utilr   r   Úcontourpy.util.bokeh_utilr   r   Úcontourpy.util.rendererr   Úbokeh.modelsr   r   Únumpy.typingr   Ú#selenium.webdriver.remote.webdriverr   Ú	contourpyr   r   Úcontourpy._contourpyr   r   r   r­   rI   rG   ú<module>rÏ      sÆ  ðØ "Ð "Ð "Ð "Ð "Ð "à 	€	€	€	Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %à 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø "Ð "Ð "Ð "Ð "Ð "Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø %Ð %Ð %Ð %Ð %Ð %Ø !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð à :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ø EÐ EÐ EÐ EÐ EÐ EÐ EÐ EØ ,Ð ,Ð ,Ð ,Ð ,Ð ,àð <Ø%Ð%Ð%Ð%Ð%Ð%Ø&Ð&Ð&Ð&Ð&Ð&Ø&Ð&Ð&Ð&Ð&Ð&Ø=Ð=Ð=Ð=Ð=Ð=à,Ð,Ð,Ð,Ð,Ð,Ð,Ð,Ø;Ð;Ð;Ð;Ð;Ð;Ð;Ð;ðtTð tTð tTð tTð tT�Hñ tTô tTð tTð tTð tTrI   