Ë
    ¨eh®~  ã                   óÎ  — d Z ddlZddlZddlmZ ddlZddlZddlmZ ddl	m
Z
 ddlZddlZddlZddlZddlZddlmZmZ ddlmZ ddlZddlmZ ddlZdd	lmZ ddlmZ dd
lmZmZ  ej@                  d«       dZ!d„ Z"d„ Z#d„ Z$d„ Z% G d„ de«      Z&d„ Z'd„ Z(d„ Z)d„ Z*dZ+e+dz   Z,e+dz   Z-dZ. e/«       Z0 G d„ d«      Z1d&d„Z2 G d„ de3«      Z4d'd „Z5d(d!„Z6d"„ Z7d#„ Z8	 	 	 d)d$„Z9d%„ Z:y)*aÒ  
A directive for including a Matplotlib plot in a Sphinx document
================================================================

This is a Sphinx extension providing a reStructuredText directive
``.. plot::`` for including a plot in a Sphinx document.

In HTML output, ``.. plot::`` will include a .png file with a link
to a high-res .png and .pdf.  In LaTeX output, it will include a .pdf.

The plot content may be defined in one of three ways:

1. **A path to a source file** as the argument to the directive::

     .. plot:: path/to/plot.py

   When a path to a source file is given, the content of the
   directive may optionally contain a caption for the plot::

     .. plot:: path/to/plot.py

        The plot caption.

   Additionally, one may specify the name of a function to call (with
   no arguments) immediately after importing the module::

     .. plot:: path/to/plot.py plot_function1

2. Included as **inline content** to the directive::

     .. plot::

        import matplotlib.pyplot as plt
        plt.plot([1, 2, 3], [4, 5, 6])
        plt.title("A plotting exammple")

3. Using **doctest** syntax::

     .. plot::

        A plotting example:
        >>> import matplotlib.pyplot as plt
        >>> plt.plot([1, 2, 3], [4, 5, 6])

Options
-------

The ``.. plot::`` directive supports the following options:

``:format:`` : {'python', 'doctest'}
    The format of the input.  If unset, the format is auto-detected.

``:include-source:`` : bool
    Whether to display the source code. The default can be changed using
    the ``plot_include_source`` variable in :file:`conf.py` (which itself
    defaults to False).

``:show-source-link:`` : bool
    Whether to show a link to the source in HTML. The default can be
    changed using the ``plot_html_show_source_link`` variable in
    :file:`conf.py` (which itself defaults to True).

``:context:`` : bool or str
    If provided, the code will be run in the context of all previous plot
    directives for which the ``:context:`` option was specified.  This only
    applies to inline code plot directives, not those run from files. If
    the ``:context: reset`` option is specified, the context is reset
    for this and future plots, and previous figures are closed prior to
    running the code. ``:context: close-figs`` keeps the context but closes
    previous figures before running the code.

``:nofigs:`` : bool
    If specified, the code block will be run, but no figures will be
    inserted.  This is usually useful with the ``:context:`` option.

``:caption:`` : str
    If specified, the option's argument will be used as a caption for the
    figure. This overwrites the caption given in the content, when the plot
    is generated from a file.

Additionally, this directive supports all the options of the `image directive
<https://docutils.sourceforge.io/docs/ref/rst/directives.html#image>`_,
except for ``:target:`` (since plot will add its own target).  These include
``:alt:``, ``:height:``, ``:width:``, ``:scale:``, ``:align:`` and ``:class:``.

Configuration options
---------------------

The plot directive has the following configuration options:

plot_include_source
    Default value for the include-source option (default: False).

plot_html_show_source_link
    Whether to show a link to the source in HTML (default: True).

plot_pre_code
    Code that should be executed before each plot. If None (the default),
    it will default to a string containing::

        import numpy as np
        from matplotlib import pyplot as plt

plot_basedir
    Base directory, to which ``plot::`` file names are relative to.
    If None or empty (the default), file names are relative to the
    directory where the file containing the directive is.

plot_formats
    File formats to generate (default: ['png', 'hires.png', 'pdf']).
    List of tuples or strings::

        [(suffix, dpi), suffix, ...]

    that determine the file format and the DPI. For entries whose
    DPI was omitted, sensible defaults are chosen. When passing from
    the command line through sphinx_build the list should be passed as
    suffix:dpi,suffix:dpi, ...

plot_html_show_formats
    Whether to show links to the files in HTML (default: True).

plot_rcparams
    A dictionary containing any non-standard rcParams that should
    be applied before each plot (default: {}).

plot_apply_rcparams
    By default, rcParams are applied when ``:context:`` option is not used
    in a plot directive.  If set, this configuration option overrides this
    behavior and applies rcParams before each plot.

plot_working_directory
    By default, the working directory will be changed to the directory of
    the example, so the code can get at its data files, if any.  Also its
    path will be added to `sys.path` so it can import any helper modules
    sitting beside it.  This configuration option can be used to specify
    a central directory (also added to `sys.path`) where data files and
    helper modules for all code are located.

plot_template
    Provide a customized template for preparing restructured text.

plot_srcset
    Allow the srcset image option for responsive image resolutions. List of
    strings with the multiplicative factors followed by an "x".
    e.g. ["2.0x", "1.5x"].  "2.0x" will create a png with the default "png"
    resolution from plot_formats, multiplied by 2. If plot_srcset is
    specified, the plot directive uses the
    :doc:`/api/sphinxext_figmpl_directive_api` (instead of the usual figure
    directive) in the intermediary rst file that is generated.
    The plot_srcset option is incompatible with *singlehtml* builds, and an
    error will be raised.

Notes on how it works
---------------------

The plot directive runs the code it is given, either in the source file or the
code under the directive. The figure created (if any) is saved in the sphinx
build directory under a subdirectory named ``plot_directive``.  It then creates
an intermediate rst file that calls a ``.. figure:`` directive (or
``.. figmpl::`` directive if ``plot_srcset`` is being used) and has links to
the ``*.png`` files in the ``plot_directive`` directory.  These translations can
be customized by changing the *plot_template*.  See the source of
:doc:`/api/sphinxext_plot_directive_api` for the templates defined in *TEMPLATE*
and *TEMPLATE_SRCSET*.
é    N)ÚStringIO)Úrelpath)ÚPath)Ú
directivesÚ	Directive)ÚImage)ÚExtensionError)ÚFigureManagerBase)Ú_pylab_helpersÚcbookÚaggé   c                 óÈ   — | r| j                  «       sy| j                  «       j                  «       dv ry| j                  «       j                  «       dv ryt        | ›d�«      ‚)NT)ÚnoÚ0ÚfalseF)ÚyesÚ1Útruez unknown boolean)ÚstripÚlowerÚ
ValueError©Úargs    úa/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/matplotlib/sphinxext/plot_directive.pyÚ_option_booleanr   Ê   sY   € Ù�c—i‘i”kàØ	�‰‹×	Ñ	Ó	Ð 4Ñ	4ØØ	�‰‹×	Ñ	Ó	Ð 4Ñ	4Øä˜C˜7Ð"2Ð3Ó4Ð4ó    c                 ó$   — | dv r| S t        d«      ‚)N)NÚresetú
close-figsz2Argument should be None or 'reset' or 'close-figs')r   r   s    r   Ú_option_contextr!   Ö   s   € Ø
Ð+Ñ+Øˆ
Ü
ÐIÓ
JÐJr   c                 ó.   — t        j                  | d«      S )N)ÚpythonÚdoctest)r   Úchoicer   s    r   Ú_option_formatr&   Ü   s   € Ü×Ñ˜SÐ"7Ó8Ð8r   c                 ó`  — |j                   j                  «       D �]  \  }}|sŒ
|j                  |   }|€Œ|j                  |   }|j                  dv sŒ:|D ]Ò  }|j                  dk(  sŒ|}|D ]#  }|j                  dk(  sŒ|j                  «       } n |d   j                  |«       |d   j                  |«       |d   j                  |«       |d   j                  |«       |j                  j                  j                  ||f|j                  j                  j                  |<    �Œ �Œ y)z”
    To make plots referenceable, we need to move the reference from the
    "htmlonly" (or "latexonly") node to the actual figure node itself.
    N)Ú	html_onlyÚ
latex_onlyÚfigureÚcaptionÚidsÚnames)Ú	nametypesÚitemsÚnameidsr,   ÚtagnameÚastextÚremoveÚappendÚsettingsÚenvÚdocnameÚlabels)	ÚappÚdocumentÚnameÚexplicitÚlabelidÚnodeÚnÚsectnameÚcs	            r   Úmark_plot_labelsrB   à   s+  € ð
 #×,Ñ,×2Ñ2Ó4ó ‰ˆˆhÙØØ×"Ñ" 4Ñ(ˆØˆ?ØØ�|‰|˜GÑ$ˆØ�<‰<Ð6Ò6Øò �Ø—9‘9 Ó(Ø#�HØò "˜ØŸ9™9¨	Ó1Ø'(§x¡x£z˜HÙ!ð"ð
 ˜‘K×&Ñ& wÔ/Ø˜‘M×(Ñ(¨Ô.Ø�e‘H—O‘O GÔ,Ø�g‘J×%Ñ% dÔ+à ×)Ñ)×-Ñ-×5Ñ5°wÀÐHð ×%Ñ%×)Ñ)×0Ñ0°Ñ6âòñr   c                   óä   — e Zd ZdZdZdZdZdZej                  ej                  ej                  ej                  ej                  ej                  eeeeej&                  ej                  dœZd„ Zy)	ÚPlotDirectivezEThe ``.. plot::`` directive, as documented in the module's docstring.Tr   r   F)ÚaltÚheightÚwidthÚscaleÚalignÚclassúinclude-sourceúshow-source-linkÚformatÚcontextÚnofigsr+   c                 óò   — 	 t        | j                  | j                  | j                  | j                  | j
                  | j                  «      S # t        $ r}| j                  t        |«      «      ‚d}~ww xY w)zRun the plot directive.N)
ÚrunÚ	argumentsÚcontentÚoptionsÚstate_machineÚstateÚlinenoÚ	ExceptionÚerrorÚstr)ÚselfÚes     r   rQ   zPlotDirective.run  s`   € ð	%Ü�t—~‘~ t§|¡|°T·\±\Ø×)Ñ)¨4¯:©:°t·{±{óDð Døäò 	%Ø—*‘*œS ›VÓ$Ð$ûð	%ús   ‚AA Á	A6ÁA1Á1A6N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úhas_contentÚrequired_argumentsÚoptional_argumentsÚfinal_argument_whitespacer   Ú	unchangedÚlength_or_unitlessÚ length_or_percentage_or_unitlessÚnonnegative_intr   rI   Úclass_optionr   r&   r!   ÚflagÚoption_specrQ   © r   r   rD   rD   þ   sx   „ ÙOà€KØÐØÐØ %Ðà×#Ñ#Ø×/Ñ/Ø×<Ñ<Ø×+Ñ+Ø—‘Ø×(Ñ(Ø)Ø+Ø Ø"Ø—/‘/Ø×'Ñ'ñ
€Kó%r   rD   c                 ó   — |€|| j                   j                  dk(  rbt        j                  d«      }| j                  t        d«      z  }|j                  d¬«       t        j                  ||t        d«      z  «       y y y )NÚhtmlz!plot_directive/plot_directive.cssÚ_staticT©Úexist_okúplot_directive.css)	ÚbuilderrM   r   Ú_get_data_pathÚoutdirr   ÚmkdirÚshutilÚcopyfile)r9   ÚexcÚsrcÚdsts       r   Ú_copy_css_filer|     si   € Ø
€{�s—{‘{×)Ñ)¨VÒ3Ü×"Ñ"Ð#FÓGˆØ�j‰jœ4 	›?Ñ*ˆØ�	‰	˜4ˆ	Ô ä�‰˜˜S¤4Ð(<Ó#=Ñ=Õ>ð 4€{r   c                 óä  — | t         _        | j                  t         _        | j                  t         _        | j	                  dt
        «       | j                  dd d«       | j                  ddd«       | j                  ddd«       | j                  dg d¢d«       | j                  d	d d«       | j                  d
dd«       | j                  di d«       | j                  ddd«       | j                  dd d«       | j                  dd d«       | j                  dg d«       | j                  dt        «       | j                  d«       | j                  dt        «       ddt        j                  dœ}|S )NÚplotÚplot_pre_codeTÚplot_include_sourceFÚplot_html_show_source_linkÚplot_formats©Úpngz	hires.pngÚpdfÚplot_basedirÚplot_html_show_formatsÚplot_rcparamsÚplot_apply_rcparamsÚplot_working_directoryÚplot_templateÚplot_srcsetzdoctree-readrr   zbuild-finished)Úparallel_read_safeÚparallel_write_safeÚversion)Úsetupr9   ÚconfigÚconfdirÚadd_directiverD   Úadd_config_valueÚconnectrB   Úadd_css_filer|   Ú
matplotlibÚ__version__)r9   Úmetadatas     r   r�   r�   &  sB  € Ø„E„IØ—:‘:„E„LØ—K‘K„E„MØ×Ñ�fœmÔ,Ø×Ñ˜¨$°Ô5Ø×ÑÐ.°°tÔ<Ø×ÑÐ5°t¸TÔBØ×Ñ˜Ò)DÀdÔKØ×Ñ˜¨¨tÔ4Ø×ÑÐ1°4¸Ô>Ø×Ñ˜¨"¨dÔ3Ø×ÑÐ.°°tÔ<Ø×ÑÐ1°4¸Ô>Ø×Ñ˜¨$°Ô5Ø×Ñ˜¨¨DÔ1Ø‡K�K�Ô 0Ô1Ø×ÑÐ)Ô*Ø‡K�KÐ ¤.Ô1Ø&*À4Ü%×1Ñ1ñ3€Hà€Or   c                 ó¾   — 	 t        | dd«       y# t        $ r Y nw xY wt        j                   dt        j                  «      }|j	                  | «      }t        |«      S )Nz<string>ÚexecFz^\s*>>>)ÚcompileÚSyntaxErrorÚreÚMÚsearchÚbool)ÚtextÚrÚms      r   Úcontains_doctestr¥   C  sR   € ðä��j &Ô)ØøÜò Ùðúä
�
‰
�:œrŸt™tÓ$€AØ	�‰�‹€AÜ�‹7€Ns   ‚ �	›c                 ó¾  — t        | «      }|€Êg }g }| j                  d«      D ]o  }|s|j                  d«      s|rG|j                  «       dk(  r4|j	                  |«       |j	                  dj                  |«      «       g }Œ_|j	                  |«       Œq dj                  |«      j                  «       r |j	                  dj                  |«      «       ||fS | g}||fS )zSplit code at plt.show().ú
z	plt.show(z>>> plt.show())r¥   ÚsplitÚ
startswithr   r4   Újoin)r¢   Úfunction_nameÚ
is_doctestÚpartsÚpartÚlines         r   Ú_split_code_at_showr°   O  sÑ   € ô " $Ó'€JØÐØˆØˆØ—J‘J˜tÓ$ò 	"ˆDÙ D§O¡O°KÔ$@Ù 4§:¡:£<Ð3CÒ#CØ—‘˜DÔ!Ø—‘˜TŸY™Y t›_Ô-Ø‘à—‘˜DÕ!ð	"ð �9‰9�T‹?× Ñ Ô"Ø�L‰L˜Ÿ™ 4›Ô)ð �uÐÐð �ˆØ�uÐÐr   a   
{{ source_code }}

.. only:: html

   {% if src_name or (html_show_formats and not multi_image) %}
   (
   {%- if src_name -%}
   :download:`Source code <{{ build_dir }}/{{ src_name }}>`
   {%- endif -%}
   {%- if html_show_formats and not multi_image -%}
     {%- for img in images -%}
       {%- for fmt in img.formats -%}
         {%- if src_name or not loop.first -%}, {% endif -%}
         :download:`{{ fmt }} <{{ build_dir }}/{{ img.basename }}.{{ fmt }}>`
       {%- endfor -%}
     {%- endfor -%}
   {%- endif -%}
   )
   {% endif %}
a3  
   {% for img in images %}
   .. figure-mpl:: {{ build_dir }}/{{ img.basename }}.{{ default_fmt }}
      {% for option in options -%}
      {{ option }}
      {% endfor %}
      {%- if caption -%}
      {{ caption }}  {# appropriate leading whitespace added beforehand #}
      {% endif -%}
      {%- if srcset -%}
        :srcset: {{ build_dir }}/{{ img.basename }}.{{ default_fmt }}
        {%- for sr in srcset -%}
            , {{ build_dir }}/{{ img.basename }}.{{ sr }}.{{ default_fmt }} {{sr}}
        {%- endfor -%}
      {% endif %}

   {% if html_show_formats and multi_image %}
   (
    {%- for fmt in img.formats -%}
    {%- if not loop.first -%}, {% endif -%}
    :download:`{{ fmt }} <{{ build_dir }}/{{ img.basename }}.{{ fmt }}>`
    {%- endfor -%}
   )
   {% endif %}


   {% endfor %}

.. only:: not html

   {% for img in images %}
   .. figure-mpl:: {{ build_dir }}/{{ img.basename }}.*
      {% for option in options -%}
      {{ option }}
      {% endfor -%}

      {{ caption }}  {# appropriate leading whitespace added beforehand #}
   {% endfor %}

a'  

   {% for img in images %}
   .. figure:: {{ build_dir }}/{{ img.basename }}.{{ default_fmt }}
      {% for option in options -%}
      {{ option }}
      {% endfor %}

      {% if html_show_formats and multi_image -%}
        (
        {%- for fmt in img.formats -%}
        {%- if not loop.first -%}, {% endif -%}
        :download:`{{ fmt }} <{{ build_dir }}/{{ img.basename }}.{{ fmt }}>`
        {%- endfor -%}
        )
      {%- endif -%}

      {{ caption }}  {# appropriate leading whitespace added beforehand #}
   {% endfor %}

.. only:: not html

   {% for img in images %}
   .. figure:: {{ build_dir }}/{{ img.basename }}.*
      {% for option in options -%}
      {{ option }}
      {% endfor -%}

      {{ caption }}  {# appropriate leading whitespace added beforehand #}
   {% endfor %}

zi
.. only:: html

   [`source code <%(linkdir)s/%(basename)s.py>`__]

Exception occurred rendering plot.

c                   ó   — e Zd Zd„ Zd„ Zd„ Zy)Ú	ImageFilec                 ó.   — || _         || _        g | _        y ©N)ÚbasenameÚdirnameÚformats)r[   rµ   r¶   s      r   Ú__init__zImageFile.__init__Ø  s   € Ø ˆŒØˆŒØˆ�r   c                 ót   — t         j                  j                  | j                  | j                  › d|› �«      S )Nú.)ÚosÚpathrª   r¶   rµ   )r[   rM   s     r   ÚfilenamezImageFile.filenameÝ  s*   € Ü�w‰w�|‰|˜DŸL™L¨T¯]©]¨O¸1¸V¸HÐ*EÓFÐFr   c                 ó^   — | j                   D �cg c]  }| j                  |«      ‘Œ c}S c c}w r´   )r·   r½   )r[   Úfmts     r   Ú	filenameszImageFile.filenamesà  s#   € Ø.2¯l©lÖ; s�—‘˜cÕ"Ò;Ð;ùÒ;s   �*N)r]   r^   r_   r¸   r½   rÀ   rl   r   r   r²   r²   ×  s   „ òò
Gó<r   r²   c                 óÆ   ‡‡— t         j                  j                  |«      sy|€g }| g|¢}d„ Št        j                  |«      j                  Št        ˆˆfd„|D «       «      S )a4  
    Return whether *derived* is out-of-date relative to *original* or any of
    the RST files included in it using the RST include directive (*includes*).
    *derived* and *original* are full paths, and *includes* is optionally a
    list of full paths which may have been included in the *original*.
    Tc                 óˆ   — t         j                  j                  | «      xr" |t        j                  | «      j                  k  S r´   )r»   r¼   ÚexistsÚstatÚst_mtime)ÚoriginalÚderived_mtimes     r   Úout_of_date_onez$out_of_date.<locals>.out_of_date_oneò  s3   € Ü—‘—‘˜xÓ(ò ;Ø¤§¡¨Ó 1× :Ñ :Ñ:ð	<r   c              3   ó0   •K  — | ]  } ‰|‰«      –— Œ y ­wr´   rl   )Ú.0ÚfrÇ   rÈ   s     €€r   ú	<genexpr>zout_of_date.<locals>.<genexpr>÷  s   øè ø€ ÒI°Q‰˜q -×0ÑIùs   ƒ)r»   r¼   rÃ   rÄ   rÅ   Úany)rÆ   ÚderivedÚincludesÚfiles_to_checkrÇ   rÈ   s       @@r   Úout_of_daterÑ   ä  s\   ù€ ô �7‰7�>‰>˜'Ô"ØàÐØˆØÐ* Ð*€Nò<ô —G‘G˜GÓ$×-Ñ-€MÜÔI¸.ÔIÓIÐIr   c                   ó   — e Zd Zy)Ú	PlotErrorN)r]   r^   r_   rl   r   r   rÓ   rÓ   ú  s   „ Ør   rÓ   c                 ó  — t        j                  «       }t        j                  j                  �/	 t        j
                  t        j                  j                  «       nS|�Qt         j                  j                  t         j                  j                  |«      «      }t        j
                  |«       t        j                  t        |gt        j                  «       gt        j                  ¢¬«      5  t        j                  t!        «       «      5  	 |€i }|sTt        j                  j"                  €t%        d|«       n-t%        t'        t        j                  j"                  «      |«       d| v rd|d<   t        j                  t(        d„ ¬	«      5  t%        | |«       |�t%        |d
z   |«       ddd«       t        j
                  |«       	 ddd«       ddd«       |S # t        $ r}t        |› d�«      |‚d}~wt        $ r}t        |› d�«      |‚d}~ww xY w# 1 sw Y   ŒlxY w# t*        t,        f$ r#}t/        t1        j2                  «       «      |‚d}~ww xY w# t        j
                  |«       w xY w# 1 sw Y   Œ©xY w# 1 sw Y   |S xY w)zs
    Import a Python module from a path, and run the function given by
    name, if function_name is not None.
    Nz\
`plot_working_directory` option in Sphinx configuration file must be a valid directory pathzV
`plot_working_directory` option in Sphinx configuration file must be a string or None)Úargvr¼   z8import numpy as np
from matplotlib import pyplot as plt
Ú__main__r]   c                  ó   — y r´   rl   )r[   s    r   ú<lambda>z_run_code.<locals>.<lambda>'  s   � r   )Úshowz())r»   Úgetcwdr�   r‘   rŠ   ÚchdirÚOSErrorÚ	TypeErrorr¼   Úabspathr¶   r   Ú_setattr_cmÚsysÚ
contextlibÚredirect_stdoutr   r   r›   rZ   r
   rX   Ú
SystemExitrÓ   Ú	tracebackÚ
format_exc)ÚcodeÚ	code_pathÚnsr«   ÚpwdÚerrr¶   s          r   Ú	_run_coderë   þ  s"  € ô �)‰)‹+€CÜ‡|�|×*Ñ*Ð6ð		.Ü�H‰H”U—\‘\×8Ñ8Õ9ð 
Ð	Ü—'‘'—/‘/¤"§'¡'§/¡/°)Ó"<Ó=ˆÜ
�‰�Ôä	×	Ñ	Ü�y�k¬¯©«Ð(@´s·x±xÐ(@ô
Bñ ä×&Ñ&¤x£zÓ2ñð	ØˆzØ�ÙÜ—<‘<×-Ñ-Ð5Üð BØCEõGô œœUŸ\™\×7Ñ7Ó8¸"Ô=Ø˜TÑ!Ø!+��:‘ô ×"Ñ"Ô#4Ñ;LÔMñ 3Ü�T˜2”Ø Ð,Ü˜¨Ñ-¨rÔ2÷3ô �H‰H�S�M÷1÷ ð2 €IøôK ò 	6Ü˜S˜Eð "+ð ,ó -à25ð6ûô ò 	.Ü˜s˜eð $#ð $ó %à*-ð.ûð	.ú÷03ð 3ûô
 œ:Ð&ò 	=ÜœI×0Ñ0Ó2Ó3¸Ð<ûð	=ûô �H‰H�S�Mú÷1ð ú÷ ð2 €Iús�   °-G Ã1J ÄI4ÄA?H%ÆHÆ.H%Æ6I4ÇJ Ç	HÇ'G6Ç6HÈHÈHÈH"ÈH%È%IÈ4IÉIÉIÉI1É1I4É4I=	É9J Ê J
c                 ó˜   — |rt        j                  d«       t        j                  «        t        j                  j                  | «       y )NÚall)ÚpltÚcloser—   Úrc_file_defaultsÚrcParamsÚupdate)rˆ   rï   s     r   Úclear_stateró   3  s1   € ÙÜ�	‰	�%ÔÜ×ÑÔ!Ü×Ñ×Ñ˜}Õ-r   c                 óÚ  — ddddœ}g }| j                   }|D ]Ñ  }t        |t        «      rbd|v r:|j                  d«      \  }}|j	                  t        |«      t        |«      f«       ŒQ|j	                  ||j                  |d«      f«       Œut        |t        t        f«      r:t        |«      dk(  r,|j	                  t        |d   «      t        |d   «      f«       ŒÅt        d|z  «      ‚ |S )	NéP   éÈ   rƒ   ú:r   r   é   z)invalid image format "%r" in plot_formats)r‚   Ú
isinstancerZ   r¨   r4   ÚintÚgetÚtupleÚlistÚlenrÓ   )r‘   Údefault_dpir·   r‚   r¿   ÚsuffixÚdpis          r   Úget_plot_formatsr  :  s×   € Ø¨3°sÑ;€KØ€GØ×&Ñ&€LØò 
OˆÜ�cœ3ÔØ�c‰zØ!Ÿi™i¨›n‘�˜Ø—‘¤ F£¬S°«XÐ6Õ7à—‘  [§_¡_°S¸"Ó%=Ð>Õ?Ü˜œe¤T˜]Ô+´°C³¸A²Ø�N‰NœC  A¡›K¬¨S°©V«Ð5Õ6äÐGÈ#ÑMÓNÐNð
Oð €Nr   c                 ó˜   — i }| D ]B  }|j                  «       }t        |«      dk\  r|dd }||t        |«      <   Œ5t        d|›d�«      ‚ |S )z'
    Parse srcset for multiples...
    r   Néÿÿÿÿzsrcset argument z is invalid.)r   rþ   Úfloatr	   )ÚentriesÚsrcsetÚentryÚmults       r   Ú_parse_srcsetr
  L  se   € ð €FØò KˆØ—‘“ˆÜˆu‹:˜Š?Ø˜˜"�:ˆDØ"'ˆF”5˜“;Òä Ð#3°E°9¸LÐ!IÓJÐJðKð €Mr   c
                 óP  — |�|› d|› �}t        |«      }
t        | |«      \  }}t        ||«      }|
D ]C  \  }}|st        ||j	                  |«      |	¬«      rd} n|j
                  j                  |«       ŒE d}|r| |gfgS g }t        |«      D ]Ë  \  }}g }t        j                  «       D ]–  }t        |«      dkD  rt        d|||fz  |«      }nt        d||fz  |«      }|
D ]C  \  }}|st        ||j	                  |«      |	¬«      rd} n|j
                  j                  |«       ŒE |s|d	kD  } n|j                  |«       Œ˜ |s n|j                  ||f«       ŒÍ d}|r|S g }|rt        ni }|r)t        |j                  «       t        j                  «        | xs |}t        |«      D �]!  \  }}|r|j                  rt        |j                  |«       n|rt!        j"                  d
«       t%        |rt'        j(                  |«      n||||«       g }t*        j,                  j/                  «       }t        |«      D �]x  \  }}t        |«      dk(  rt        |«      dk(  rt        ||«      }n2t        |«      dk(  rt        d||fz  |«      }nt        d|||fz  |«      }|j                  |«       |
D �]   \  }}	 |j0                  j2                  j5                  |j	                  |«      |¬«       ||
d	   d	   k(  r�|j6                  r‘t9        |j6                  «      }|j;                  «       D ]i  \  }}|› d|› �}|j
                  j                  |«       |j0                  j2                  j5                  |j	                  |«      t=        ||z  «      ¬«       Œk |j
                  j                  |«       �Œ �Œ{ |j                  ||f«       �Œ$ |r|j                  rt        |j                  | ¬«       |S # t>        $ r#}tA        tC        jD                  «       «      |‚d}~ww xY w)z™
    Run a pyplot script and save the images in *output_dir*.

    Save the images under *output_dir* with file names derived from
    *output_base*
    NÚ_)rÏ   FTrø   z%s_%02d_%02dz%s_%02dr   rí   )r  rº   )rï   )#r  r°   r²   rÑ   r½   r·   r4   Ú	enumerateÚ	itertoolsÚcountrþ   Úplot_contextró   rˆ   Úclearr‰   rî   rï   rë   r$   Úscript_from_examplesr   ÚGcfÚget_all_fig_managersÚcanvasr*   ÚsavefigrŒ   r
  r/   rú   rX   rÓ   rä   rå   )ræ   rç   Ú
output_dirÚoutput_baserN   r«   r‘   Úcontext_resetÚ
close_figsÚcode_includesr·   r¬   Úcode_piecesÚimgrM   r  Ú
all_existsÚresultsÚiÚ
code_pieceÚimagesÚjr¿   rè   Úfig_managersÚfigmanr  r	  r   Úfmrê   s                                  r   Úrender_figuresr'  [  s6  € ð Ð Ø$˜ Q } oÐ6ˆÜ˜vÓ&€Gô 2°$¸ÓFÑ€J�ä
�K Ó
,€CØò ‰ˆ�Ù”k )¨S¯\©\¸&Ó-AØ+8õ:àˆJÙØ�‰×Ñ˜6Õ"ðð ˆ
áØ˜�u�ˆÐð €GÜ" ;Ó/ò ‰ˆˆ:ØˆÜ—‘Ó"ò 	ˆAÜ�;Ó !Ò#Ü °+¸qÀ!Ð1DÑ DØ *ó,‘ô   	¨[¸!Ð,<Ñ <¸jÓI�Ø#ò (‘��SÙœk¨)°S·\±\À#Ó5FØ3@õBà!&�JÙØ—‘×"Ñ" 3Õ'ð(ñ Ø !™e�
ÙØ�M‰M˜#Õð#	ñ$ ÙØ�‰˜
 FÐ+Õ,ð-ð0 ˆ
áØˆð €GÙ � b€BáÜ�F×(Ñ(Ô)Ü×ÑÔà�Ò* 
€Jä" ;Ó/ó &-‰ˆˆ:á˜&×4Ò4Ü˜×,Ñ,¨jÕ9ÙÜ�I‰I�eÔä¹j”'×.Ñ.¨zÔ:Ø!Ø˜R ô	0ð ˆÜ%×)Ñ)×>Ñ>Ó@ˆÜ" <Ó0ó 	(‰IˆAˆvÜ�<Ó  AÒ%¬#¨kÓ*:¸aÒ*?Ü ¨ZÓ8‘Ü�[Ó! QÒ&Ü 	¨[¸!Ð,<Ñ <¸jÓI‘ä °+¸qÀ!Ð1DÑ DØ *ó,�à�M‰M˜#Ôà#ó (‘��SðEØ—M‘M×(Ñ(×0Ñ0°·±¸cÓ1BÈÐ0ÔLØ˜g a™j¨™mÒ+°×0BÒ0Bä!.¨v×/AÑ/AÓ!B˜Ø,2¯L©L«Nò N™L˜D &Ø$* 8¨1¨S¨EÐ!2˜BØŸK™K×.Ñ.¨rÔ2Ø"ŸM™M×0Ñ0×8Ñ8¸¿¹ÀbÓ9IÜ=@ÀÀtÁ»_ð 9õ NðNð —‘×"Ñ" 3Ö'ò(ð	(ð2 	�‰˜
 FÐ+Ö,ðM&-ñP �f×0Ò0Ü�F×(Ñ(°G°Õ<à€Nøô !ò EÜ#¤I×$8Ñ$8Ó$:Ó;ÀÐDûðEús   Ê<CO9Ï9	P%	ÐP 	Ð P%	c                 ó˜  — |j                   }|j                  j                  j                  }d|v }|j                  r2t
        j                  j                  j                  dk(  rt        d«      ‚t        |«      }	|	d   d   }
|j                  d|j                  «       |j                  d|j                  «       d|v rdg|d   z   |d<   n|j                  ddg«       d	|v }|sd n|d	   }|j                  d
   }t        j                   j#                  |«      }t%        | «      �r,|j&                  sYt        j                   j)                  t
        j                  j                  j*                  t-        j.                  | d   «      «      }nOt        j                   j)                  t
        j0                  |j&                  t-        j.                  | d   «      «      }dj)                  |«      }d|v r|rt3        d«      ‚|d   }t%        | «      dk(  r| d   }nd }t5        |«      j7                  d¬«      }t        j                   j9                  |«      }n¼|}t;        j<                  dj)                  t?        t@        |«      «      «      }|j                  jC                  dd«      dz   }||j                  d<   t        j                   jE                  t        j                   j9                  |«      «      \  }}d||fz  }d }|jC                  dd«      }t        j                   jE                  |«      \  }}|dv r|}nd}|jG                  dd«      }tI        |«      }d|v r|d   dk(  rd}nd}tK        |t
        j0                  «      }t        j                   j#                  |«      jM                  t        j                   jN                  «      }t        j                   j)                  t        j                   j#                  t
        j                  jP                  «      d|«      }t        j                   jS                  |«      }t        jT                  |d¬«       	 tK        ||«      jG                  t        j                   jN                  d«      }	 |j                   jV                  D �cg c]7  }t        j                   j)                  t        jX                  «       |d   «      ‘Œ9 }}	 |jc                  |«       |d   r<t5        |||z   «      je                  ||k(  r|rtg        jh                  |«      n|d¬«       	 tk        ||||||||dk(  |d k(  |¬!«
      }!g }"|r|j                  rd$|› �}n,|r*ddj)                  d%„ |jw                  d«      D «       «      z   }g }&ty        |!«      D �]r  \  }'\  }(})|d   rP|rdg|(j{                  «       ¢}*n(d&dgt;        j|                  |(d'«      j{                  «       ¢}*dj)                  |*«      }+nd}+|rg })|j_                  «       D �,�-cg c]  \  },}-|,d(v rd)|,› d*|-› �‘Œ }.},}-|'dk(  r|d   r||z   }/nd }/|j                  r,g t        |j                  «      j�                  «       ¢}0t‚        }1nd }0t„        }1t‡        jˆ                  |jŠ                  xs |1«      j�                  |
||/t%        |)«      dkD  |.|0|)|+|jŽ                  xr t%        |)«      |¬+«
      }2|&j‘                  |2jw                  d«      «       |&j‘                  d«       �Œu |&r|j“                  |&|¬,«       |"S # t2        $ r |}Y �Œ°w xY wc c}w # tZ        $ r� |j\                  j^                  D �ch c]3  }t        j                   j)                  t
        j0                  |d   «      ’Œ5 nc c}w }}|D � cg c]#  } t        j                   ja                  | «      r| ‘Œ% nc c} w }} Y �Œúw xY w# t2        $ r Y �Œøw xY w# tl        $ rN}#|jn                  jp                  }$|$js                  dd"ju                  |||#«      |¬#«      }%|g fg}!|%g}"Y d }#~#�Œïd }#~#ww xY wc c}-},w )-NrO   Ú
singlehtmlz9plot_srcset option not compatible with single HTML writerr   rK   rL   rJ   zplot-directiverN   Úsourcer§   r+   zGCaption specified in both content and options. Please remove ambiguity.r   rø   zutf-8)ÚencodingÚ_plot_counterz%s-%d.pyÚ )z.pyz.rstz.txtrº   ú-rM   r#   FTÚplot_directiverp   ú/r   r    )
ræ   rç   r  r  rN   r«   r‘   r  r  r  z.Exception occurred in plotting {}
 from {}:
{})r¯   z
:caption: c              3   óB   K  — | ]  }d |j                  «       z   –— Œ y­w)z      N)r   )rÊ   r¯   s     r   rÌ   zrun.<locals>.<genexpr>q  s%   è ø€ ò #DØ'+ð $,¨d¯j©j«lÕ#:ñ #Dùs   ‚z.. code-block:: pythonz    )rE   rF   rG   rH   rI   rJ   r÷   z: )
Údefault_fmtÚ	build_dirÚsrc_nameÚmulti_imagerT   r  r"  Úsource_codeÚhtml_show_formatsr+   )r*  )Jr:   r5   r6   r‘   rŒ   r�   r9   rs   r;   r	   r  Ú
setdefaultr€   r�   Ú
attributesr»   r¼   r¶   rþ   r†   rª   Úsrcdirr   Úurir’   r   r   Ú	read_textrµ   ÚtextwrapÚdedentÚmaprZ   rû   ÚsplitextÚreplacer¥   r   ÚlstripÚsepÚ
doctreedirÚnormpathÚmakedirsÚinclude_logrÚ   ÚAttributeErrorÚinput_linesr/   Úisfiler3   Ú
write_textr$   r  r'  rÓ   ÚmemoÚreporterÚsystem_messagerM   r¨   r  Ú
splitlinesÚindentr
  ÚvaluesÚTEMPLATE_SRCSETÚTEMPLATEÚjinja2ÚTemplater‹   Úrenderr‡   ÚextendÚinsert_input)3rR   rS   rT   rU   rV   rW   r:   r‘   rO   r·   r2  Úkeep_contextÚcontext_optÚrst_fileÚrst_dirÚsource_file_namer+   r«   ræ   r  ÚcounterÚbaseÚextÚ
source_extr¬   Úsource_rel_nameÚsource_rel_dirr3  Úbuild_dir_linkÚtÚsource_file_includesÚpossible_sourcesrË   r  Úerrorsrê   rM  ÚsmÚtotal_linesr#  r!  r"  Úlinesr6  ÚkeyÚvalÚoptsr4  r  ÚtemplateÚresults3                                                      r   rQ   rQ   Ó  só  € Ø×%Ñ%€HØ×Ñ×"Ñ"×)Ñ)€FØ˜Ð €Fà×ÒœeŸi™i×/Ñ/×4Ñ4¸ÒDÜØGóIð 	Iô ˜vÓ&€GØ˜!‘*˜Q‘-€Kà×ÑÐ'¨×)CÑ)CÔDØ×ÑÐ)¨6×+LÑ+LÔMà�'Ñð -Ð-°¸Ñ0@Ñ@ˆ�Òà×Ñ˜7Ð%5Ð$6Ô7Ø Ð'€LÙ*‘$°¸	Ñ0B€Kà×"Ñ" 8Ñ,€HÜ�g‰g�o‰o˜hÓ'€Gä
ˆ9…~Ø×"Ò"Ü!Ÿw™wŸ|™|¬E¯I©I×,=Ñ,=×,DÑ,DÜ,6¯N©N¸9ÀQ¹<Ó,Hó JÑô  "Ÿw™wŸ|™|¬E¯M©M¸6×;NÑ;NÜ,6¯N©N¸9ÀQ¹<Ó,Hó JÐð —)‘)˜GÓ$ˆð ˜ÑÙÜ ð0óð ð
 ˜iÑ(ˆGô ˆy‹>˜QÒØ% a™L‰Mà ˆMäÐ$Ó%×/Ñ/¸Ð/ÓAˆÜ—g‘g×&Ñ&Ð'7Ó8‰à#ÐÜ�‰˜tŸy™y¬¬S°'Ó):Ó;Ó<ˆØ×%Ñ%×)Ñ)¨/¸1Ó=ÀÑAˆØ/6ˆ×Ñ˜OÑ,Ü—G‘G×$Ñ$¤R§W¡W×%5Ñ%5Ð6FÓ%GÓH‰	ˆˆcØ  D¨' ?Ñ2ˆØˆØ—+‘+˜i¨Ó,ˆä—w‘w×'Ñ'¨Ó4Ñ€Dˆ*ØÐ,Ñ,Ø‰àˆ
ð ×%Ñ% c¨3Ó/€Kô " $Ó'€JØ�7ÑØ�8Ñ Ò(Ø‰JàˆJô Ð.´·±Ó>€OÜ—W‘W—_‘_ _Ó5×<Ñ<¼R¿W¹W¿[¹[ÓI€Nô —‘—‘œRŸW™WŸ_™_¬U¯Y©Y×-AÑ-AÓBØ-Ø+ó-€Iô —‘× Ñ  Ó+€IÜ‡K�K�	 DÕ)ð#Ü  ¨GÓ4×<Ñ<¼R¿W¹W¿[¹[È#ÓNˆð	6à).¯©×)CÑ)Cö EØ$%ô !#§¡§¡¬R¯Y©Y«[¸!¸A¹$Õ ?ð  EÐð  EðØ×#Ñ#Ð$4Ô5ð
 Ð!Ò"ÜˆY˜ jÑ0Ó1×<Ñ<à 8Ò+±
ô ×(Ñ(¨Ô.àØð	 	=ô 	ðÜ  dØ+;Ø,5Ø-8Ø)5Ø/<Ø(.Ø/:¸gÑ/EØ,7¸<Ñ,GØ/Cô	Eˆð ˆñ �6×%Ò%Ø˜w˜iÐ(‰Ù	Ø˜Ÿ™ñ #DØ/6¯}©}¸TÓ/Bô#Dó Dñ Dˆð €KÜ#,¨WÓ#5ó +!ÑˆÑˆJ˜ØÐ#Ò$ÙØÐ6˜j×3Ñ3Ó5Ð6‘à1°2ð LÜ"Ÿ/™/¨*°fÓ=×HÑHÓJðL�àŸ)™) EÓ*‰KàˆKáØˆFð .5¯]©]«_÷MÙ!)  cØÐKÑKð �ˆu�B�s�eÒðMˆñ Mð �Š6�gÐ0Ò1Ø" ZÑ/‰HàˆHØ×ÒØB”} V×%7Ñ%7Ó8×?Ñ?ÓAÐBˆFÜ&‰HàˆFÜˆHä—‘ ×!5Ñ!5Ò!A¸ÓB×IÑIØ#Ø$ØÜ˜F› a™ØØØØ#Ø$×;Ñ;ÒKÄÀFÃØð Jó 
ˆð 	×Ñ˜6Ÿ<™<¨Ó-Ô.Ø×Ñ˜4Ö ðW+!ñZ Ø×"Ñ" ;Ð7GÐ"ÔHà€Møô] ò #ð #‹ð#üò Eøäò 6ð &3×%>Ñ%>×%DÑ%DöFØ !ô ŸG™GŸL™L¬¯©¸¸!¹Õ=ñ Fùò FÐð Fà+;ö  6 aÜ#%§7¡7§>¡>°!Ô#4ò !"ñ  6ùò  6Ðó  6ð6ûô ò Úðûô0 ò Ø—:‘:×&Ñ&ˆØ×$Ñ$ØÐA×HÑHØÐ-¨só4àð %ó ˆð ˜"�:�,ˆØ�Žûðüó>Ms   Ñ4\) Ò]  Ò <\;Ó]  Ó_ Ô2_, ØaÜ)\8Ü7\8Ü;]  Ý !_Ý!8^Þ_Þ%(_ß_ß_ß	_)ß(_)ß,	aß5A`>à>ar´   )NN)T)FFN);r`   rá   r$   Úior   r  r»   Úos.pathr   Úpathlibr   rž   rw   rà   r=  rä   Údocutils.parsers.rstr   r   Ú&docutils.parsers.rst.directives.imagesr   rT  Úsphinx.errorsr	   r—   Úmatplotlib.backend_basesr
   Úmatplotlib.pyplotÚpyplotrî   r   r   Úuser˜   r   r!   r&   rB   rD   r|   r�   r¥   r°   Ú_SOURCECODErR  rS  Úexception_templateÚdictr  r²   rÑ   ÚRuntimeErrorrÓ   rë   ró   r  r
  r'  rQ   rl   r   r   ú<module>r     s  ðñeóN Û Ý Û Û 	Ý Ý Û 	Û Û 
Û Û ç 6Ý 8Û å (ã Ý 6Ý ß ,à €
‡�ˆuÔ à€ò	5òKò9òô<%�Iô %ò>?òò:	òð4€ð, ð '!ñ '€ðR ð ñ €ðBÐ ñ ‹v€÷
<ñ 
<óJô,	�ô 	ó2ój.òò$ð  9>Ø#Ø!%óuópRr   