
    h~                        S r SSKrSSKrSSKJr  SSKrSSKrSSKJr  SSK	J
r
  SSKrSSKrSSKrSSKrSSKrSSKJrJr  SSKJr  SSKrSSKJr  SSKrSS	KJr  SSKJr  SS
KJrJr  \R@                  " S5        Sr!S r"S r#S r$S r% " S S\5      r&S r'S r(S r)S r*Sr+\+S-   r,\+S-   r-Sr.\/" 5       r0 " S S5      r1S&S jr2 " S S\35      r4S'S  jr5S(S! jr6S" r7S# r8   S)S$ jr9S% r:g)*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                     U (       a  U R                  5       (       d  gU R                  5       R                  5       S;   a  gU R                  5       R                  5       S;   a  g[        U < S35      e)NT)no0falseF)yes1truez unknown boolean)striplower
ValueErrorargs    U/var/www/html/env/lib/python3.13/site-packages/matplotlib/sphinxext/plot_directive.py_option_booleanr      s[    ciikk				 4	4				 4	4C7"2344    c                 (    U S;   a  U $ [        S5      e)N)Nreset
close-figsz2Argument should be None or 'reset' or 'close-figs')r   r   s    r   _option_contextr!      s    
++

I
JJr   c                 0    [         R                  " U S5      $ )N)pythondoctest)r   choicer   s    r   _option_formatr&      s    S"788r   c                    UR                   R                  5        GH!  u  p#U(       d  M  UR                  U   nUc  M#  UR                  U   nUR                  S;   d  MD  U H  nUR                  S:X  d  M  UnU H%  nUR                  S:X  d  M  UR                  5       n  O   US   R                  U5        US   R                  U5        US   R                  U5        US   R                  U5        UR                  R                  R                  XG4UR                  R                  R                  U'     GM     GM$     g)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""4(?||G$<<6699(#H99	1'(xxzH! 
 K&&w/M((.eHOOG,gJ%%d+ ))--55wH %%))006  5r   c                       \ rS rSrSrSrSrSrSr\	R                  \	R                  \	R                  \	R                  \R                  \	R                   \\\\\	R(                  \	R                  S.rS rS	rg
)PlotDirective   zEThe ``.. 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                      [        U R                  U R                  U R                  U R                  U R
                  U R                  5      $ ! [         a  nU R                  [        U5      5      eSnAff = f)zRun the plot directive.N)
run	argumentscontentoptionsstate_machinestatelineno	Exceptionerrorstr)selfes     r   rR   PlotDirective.run  s`    	%t~~t||T\\))4::t{{D D 	%**SV$$	%s   AA 
A7A22A7 N)__name__
__module____qualname____firstlineno____doc__has_contentrequired_argumentsoptional_argumentsfinal_argument_whitespacer   	unchangedlength_or_unitless length_or_percentage_or_unitlessnonnegative_intr   rJ   class_optionr   r&   r!   flagoption_specrR   __static_attributes__r_   r   r   rD   rD      sx    OK %##//<<++(()+ "//''
K%r   rD   c                     Uc{  U R                   R                  S:X  a`  [        R                  " S5      nU R                  [        S5      -  nUR                  SS9  [        R                  " X#[        S5      -  5        g g g )Nhtmlz!plot_directive/plot_directive.css_staticTexist_okplot_directive.css)	builderrN   r   _get_data_pathoutdirr   mkdirshutilcopyfile)r9   excsrcdsts       r   _copy_css_filer     sg    
{s{{))V3""#FGjj4	?*		4	 4(<#==> 4{r   c                    U [         l        U R                  [         l        U R                  [         l        U R	                  S[
        5        U R                  SS S5        U R                  SSS5        U R                  SSS5        U R                  S/ SQS5        U R                  S	S S5        U R                  S
SS5        U R                  S0 S5        U R                  SSS5        U R                  SS S5        U R                  SS S5        U R                  S/ S5        U R                  S[        5        U R                  S5        U R                  S[        5        SS[        R                  S.nU$ )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-readrv   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   EI::ELKKEMfm,$5.t<5tTB)DdKt414>"d3.t<14>$5D1KK 01)*KK .1&*4%113HOr   c                      [        U SS5        g! [         a     Of = f[        R                   " S[        R                  5      nUR	                  U 5      n[        U5      $ )Nz<string>execFz^\s*>>>)compileSyntaxErrorreMsearchbool)textrms      r   contains_doctestr   C  sR    j&) 


:rtt$A	A7Ns    
c                    [        U 5      nUc  / n/ nU R                  S5       H  nU(       d  UR                  S5      (       d  U(       aI  UR                  5       S:X  a5  UR	                  U5        UR	                  SR                  U5      5        / nMp  UR	                  U5        M     SR                  U5      R                  5       (       a   UR	                  SR                  U5      5        X#4$ U /nX#4$ )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JJt$DDOOK$@$@4::<3C#CD!TYYt_-D! % 99T?  ""LL4)  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                   &    \ rS rSrS rS rS rSrg)	ImageFilei  c                 *    Xl         X l        / U l        g Nbasenamedirnameformats)r\   r   r   s      r   __init__ImageFile.__init__  s     r   c                 t    [         R                  R                  U R                  U R                   SU 35      $ )N.)ospathr   r   r   )r\   rN   s     r   filenameImageFile.filename  s*    ww||DLLT]]O1VH*EFFr   c                 b    U R                    Vs/ s H  oR                  U5      PM     sn$ s  snf r   )r   r   )r\   fmts     r   	filenamesImageFile.filenames  s%    .2ll;lsc"l;;;s   ,r   N)r`   ra   rb   rc   r   r   r   rp   r_   r   r   r   r     s    
G<r   r   c                    ^^ [         R                  R                  U5      (       d  gUc  / nU /UQnS m[         R                  " U5      R                  m[        UU4S jU 5       5      $ )a   
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                     [         R                  R                  U 5      =(       a#    U[         R                  " U 5      R                  :  $ r   )r   r   existsstatst_mtime)originalderived_mtimes     r   out_of_date_one$out_of_date.<locals>.out_of_date_one  s3    x( ; 1 : ::	<r   c              3   6   >#    U  H  nT" UT5      v   M     g 7fr   r_   ).0fr   r   s     r   	<genexpr>out_of_date.<locals>.<genexpr>  s     I.Qq-00.s   )r   r   r   r   r   any)r   derivedincludesfiles_to_checkr   r   s       @@r   out_of_dater     s_     77>>'""**N< GGG$--MI.IIIr   c                       \ rS rSrSrg)	PlotErrori  r_   N)r`   ra   rb   rc   rp   r_   r   r   r   r     s    r   r   c                 \   [         R                  " 5       n[        R                  R                  b0   [         R
                  " [        R                  R                  5        OUUbR  [         R                  R                  [         R                  R                  U5      5      n[         R
                  " U5        [        R                  " [        U/[         R                  " 5       /[        R                  QS9   [        R                  " [!        5       5          Uc  0 nU(       dU  [        R                  R"                  c  [%        SU5        O-[%        ['        [        R                  R"                  5      U5        SU ;   a  SUS'   [        R                  " [(        S S	9   [%        X5        Ub  [%        US
-   U5        SSS5        [         R
                  " U5         SSS5        SSS5        U$ ! [         a  n[        U S35      UeSnAf[         a  n[        U S35      UeSnAff = f! , (       d  f       Nt= f! [*        [,        4 a$  n[/        [0        R2                  " 5       5      UeSnAff = f! [         R
                  " U5        f = f! , (       d  f       N= f! , (       d  f       U$ = f)zg
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                     g r   r_   )r\   s    r   <lambda>_run_code.<locals>.<lambda>'  s    r   )showz())r   getcwdr   r   r   chdirOSError	TypeErrorr   abspathr   r   _setattr_cmsys
contextlibredirect_stdoutr   r   r   r[   r
   rY   
SystemExitr   	traceback
format_exc)code	code_pathnsr   pwderrr   s          r   	_run_coder     s    ))+C||**6		.HHU\\889 
	''//"''//)"<=
			yk(@sxx(@
B&&xz2	z<<--5 BCEG U\\778"=T!!+: ""#4;LMT ,-r2 N HHSM- 3
B2 IK  	6SE "+ , -256  	.se $# $ %*-.	.0 NM
 :& 	=I0023<	= HHSM- 32
B 
B2 Is   .G+ 5JJBH9H(:H9JJ+
H%5HH%H  H%(
H62H95I06H99I-	I((I--I00JJ
J	J
J+c                     U(       a  [         R                  " S5        [        R                  " 5         [        R                  R                  U 5        g )Nall)pltcloser   rc_file_defaultsrcParamsupdate)r   r   s     r   clear_stater   3  s1    		%!}-r   c                    SSSS.n/ nU R                   nU H  n[        U[        5      (       ad  SU;   a:  UR                  S5      u  pVUR	                  [        U5      [        U5      45        MX  UR	                  XAR                  US5      45        M|  [        U[        [        45      (       a<  [        U5      S:X  a-  UR	                  [        US   5      [        US   5      45        M  [        SU-  5      e   U$ )	NP      r   :r   r      z)invalid image format "%r" in plot_formats)r   
isinstancer[   r   r4   intgettuplelistlenr   )r   default_dpir   r   r   suffixdpis          r   get_plot_formatsr  :  s    3s;KG&&Lc3cz!iinFSX67__S"%=>?eT]++CANNCAKSV56G#MNN  Nr   c                     0 nU  HD  nUR                  5       n[        U5      S:  a  USS nX![        U5      '   M6  [        SU< S35      e   U$ )z
Parse srcset for multiples...
r   Nzsrcset argument z is invalid.)r   r	  floatr	   )entriessrcsetentrymults       r   _parse_srcsetr  L  s\     Fu:?":D"'5; #3E9L!IJJ  Mr   c
                 	   Ub  U SU 3n[        U5      n
[        X5      u  p[        X25      nU
 HI  u  pU(       d  [        XR	                  U5      U	S9(       a  Sn  O!UR
                  R                  U5        MK     SnU(       a  X/4/$ / n[        U5       H  u  nn/ n[        R                  " 5        H  n[        U5      S:  a  [        SUUU4-  U5      nO[        SUU4-  U5      nU
 HJ  u  nnU(       d  [        XR	                  U5      U	S9(       a  Sn  OUR
                  R                  U5        ML     U(       d  US	:  n  OUR                  U5        M     U(       d    OUR                  UU45        M     SnU(       a  U$ / nU(       a  [        O0 nU(       a)  [        UR                  5        [        R                  5         U(       + =(       d    Un[        U5       GH@  u  nnU(       a  UR                  (       a  [        UR                  U5        OU(       a  [         R"                  " S
5        [%        U(       a  [&        R(                  " U5      OUUUU5        / n[*        R,                  R/                  5       n[        U5       GH  u  nn[        U5      S:X  a  [        U5      S:X  a  [        X25      nO3[        U5      S:X  a  [        SUU4-  U5      nO[        SUUU4-  U5      nUR                  U5        U
 GH  u  nn UR0                  R2                  R5                  UR	                  U5      US9  UU
S	   S	   :X  a  UR6                  (       a  [9        UR6                  5      nUR;                  5        Hg  u  nnU SU 3nUR
                  R                  U5        UR0                  R2                  R5                  UR	                  U5      [=        UU-  5      S9  Mi     UR
                  R                  U5        GM     GM     UR                  UU45        GMC     U(       a  UR                  (       a  [        UR                  U(       + S9  U$ ! [>         a$  n[A        [B        RD                  " 5       5      UeSnAff = f)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  rY   r   r   r   )r   r   
output_diroutput_baserO   r   r   context_reset
close_figscode_includesr   r   code_piecesimgrN   r  
all_existsresultsi
code_pieceimagesjr   r   fig_managersfigmanr  r  r  fmr   s                                  r   render_figuresr2  [  s     $Q}o6v&G 2$FJ
K
,Ck)\\&-A+8:J6"  
u G";/:"A;!#+q!1D D *,  	[!,< <jI#Sk)\\#5F3@B!&J""3' $ !e
MM## #$ 
F+,- 00 
 G bBF(()*
J";/:&44,,j9IIej'..z:!R	0 %))>>@"<0IAv< A%#k*:a*?8[!Q&	[!,< <jI+q!1D D *,MM##SEMM((00c1B0Lgajm+0B0B!.v/A/A!B,2LLNLD&$*81SE!2BKK..r2"MM0088b9I=@t_ 9 N -; ""3' $ 12 	
F+,M 0P f00F((G<N ! E#I$8$8$:;DEs   C Q
R	'R	R	c                    UR                   nUR                  R                  R                  nSU;   nUR                  (       a3  [
        R                  R                  R                  S:X  a  [        S5      e[        U5      n	U	S   S   n
UR                  SUR                  5        UR                  SUR                  5        SU;   a  S/US   -   US'   OUR                  SS/5        S	U;   nU(       d  S OUS	   nUR                  S
   n[        R                   R#                  U5      n[%        U 5      (       Ga8  UR&                  (       dZ  [        R                   R)                  [
        R                  R                  R*                  [,        R.                  " U S   5      5      nOP[        R                   R)                  [
        R0                  UR&                  [,        R.                  " U S   5      5      nSR)                  U5      nSU;   a  U(       a  [3        S5      eUS   n[%        U 5      S:X  a  U S   nOS n[5        U5      R7                  SS9n[        R                   R9                  U5      nOUn[:        R<                  " SR)                  [?        [@        U5      5      5      nUR                  RC                  SS5      S-   nUUR                  S'   [        R                   RE                  [        R                   R9                  U5      5      u  nnSUU4-  nS nURC                  SS5      n[        R                   RE                  U5      u  nnUS;   a  UnOSnURG                  SS5      n[I        U5      nSU;   a  US   S:X  a  SnOSn[K        U[
        R0                  5      n[        R                   R#                  U5      RM                  [        R                   RN                  5      n[        R                   R)                  [        R                   R#                  [
        R                  RP                  5      SU5      n[        R                   RS                  U5      n[        RT                  " USS9   [K        UU5      RG                  [        R                   RN                  S5      n UR                   RV                   Vs/ s H9  n[        R                   R)                  [        RX                  " 5       US   5      PM;     nn URc                  U5        US   (       a?  [5        UUU-   5      Re                  X:X  a  U(       a  [f        Rh                  " U5      OUSS9   [k        UUUUUUUUS:H  US :H  US!9
n!/ n"U(       a  UR                  (       a  S$U 3nO1U(       a*  SSR)                  S% URw                  S5       5       5      -   n/ n&[y        U!5       GH  u  n'u  n(n)US   (       aV  U(       a  S/U(R{                  5       Qn*O)S&S/[:        R|                  " U(S'5      R{                  5       Qn*SR)                  U*5      n+OSn+U(       a  / n)UR_                  5        V,V-s/ s H  u  n,n-U,S(;   d  M  S)U, S*U- 3PM     n.n,n-U'S:X  a  US   (       a  UU-   n/OS n/UR                  (       a,  / [        UR                  5      R                  5       Qn0[        n1OS n0[        n1[        R                  " UR                  =(       d    U15      R                  U
UU/[%        U)5      S:  U.U0U)U+UR                  =(       a    [%        U)5      US+9
n2U&R                  U2Rw                  S5      5        U&R                  S5        GM     U&(       a  UR                  U&US,9  U"$ ! [2         a    Un GNf = fs  snf ! [Z         a    UR\                  R^                   Vs1 s H4  n[        R                   R)                  [
        R0                  US   5      iM6     Os  snf nnU V s/ s H+  n [        R                   Ra                  U 5      (       d  M)  U PM-     Os  sn f nn  GNKf = f! [2         a     GNJf = f! [l         aK  n#URn                  Rp                  n$U$Rs                  SS"Ru                  UUU#5      US#9n%U/ 4/n!U%/n" S n#A#GN:S n#A#ff = fs  sn-n,f )-NrP   
singlehtmlz9plot_srcset option not compatible with single HTML writerr   rL   rM   rK   zplot-directiverO   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   -rN   r#   FTplot_directivert   /r   r    )
r   r   r"  r#  rO   r   r   r$  r%  r&  z.Exception occurred in plotting {}
 from {}:
{})r   z
:caption: c              3   H   #    U  H  nS UR                  5       -   v   M     g7f)z      N)r   )r   r   s     r   r   run.<locals>.<genexpr>q  s#      #D/Bt $,djjl#:/Bs    "z.. code-block:: pythonz    )rF   rG   rH   rI   rJ   rK   r  z: )
default_fmt	build_dirsrc_namemulti_imagerU   r  r-  source_codehtml_show_formatsr+   )r5  )Jr:   r5   r6   r   r   r   r9   rw   r;   r	   r  
setdefaultr   r   
attributesr   r   r   r	  r   r   srcdirr   urir   r   r   	read_textr   textwrapdedentmapr[   r  splitextreplacer   r   lstripsep
doctreedirnormpathmakedirsinclude_logr   AttributeErrorinput_linesr/   isfiler3   
write_textr$   r  r2  r   memoreportersystem_messagerN   r   r  
splitlinesindentr  valuesTEMPLATE_SRCSETTEMPLATEjinja2Templater   renderr   extendinsert_input)3rS   rT   rU   rV   rW   rX   r:   r   rP   r   r>  keep_contextcontext_optrst_filerst_dirsource_file_namer+   r   r   r#  counterbaseext
source_extr   source_rel_namesource_rel_dirr?  build_dir_linktsource_file_includespossible_sourcesr   r*  errorsr   rY  smtotal_linesr.  r,  r-  linesrB  keyvaloptsr@  r  templateresults3                                                      r   rR   rR     s   %%H""))F Feii//44DGI 	I v&G!*Q-K')C)CD)6+L+LM' --0@@7%5$67'L*$	0BK""8,Hggooh'G
9~~""!ww||EII,=,=,D,D,6NN9Q<,H J  "ww||EMM6;N;N,6NN9Q<,H J ))G$  0 
 i(G y>Q%aLM M$%///Agg&&'78#tyyS'):;<%%))/1=A/6O,GG$$RWW%5%56F%GH	c D'?2++i,ww''4D*,,
 %%c3/K "$'J78(JJ .>OWW___5<<RWW[[IN RWW__UYY-A-AB-+-I   +IKK	D)# G4<<RWW[[#N	6).)C)C E)CA !#RYY[!A$ ?)C 	  E##$45
 !"Yj01<<+
 ((.	 	= 	 d+;,5-8)5/<(./:g/E,7<,G/C	E  6%%wi(	 #D/6}}T/B#D D D K#,W#5J#$6j335612 L"//*f=HHJL))E*KKF .5]]_M-<cKK auBse_ 	 M 6g01"Z/HHB}V%7%78??ABF&HFH!5!5!ABII#$Fa#$;;KF J 
 	6<<-.4 W $6Z "";7G"HM]  # ## E 6 &3%>%>%D%DF%D GGLL!=%DF F+;  6+;a#%77>>!#4 !"+;  6  66  0  ::&&$$AHH-s4 %  ":,>Ms   74^ ,^+ A ^&^+ a "a&  b>1b>^#"^#&^+ +"a;`	a(a aaa
a#"a#&
b;0A b66b;r   )NN)T)FFN);rd   r   r$   ior   r  r   os.pathr   pathlibr   r   r{   r   rI  r   docutils.parsers.rstr   r   &docutils.parsers.rst.directives.imagesr   r`  sphinx.errorsr	   r   matplotlib.backend_basesr
   matplotlib.pyplotpyplotr   r   r   user   r   r!   r&   rB   rD   r   r   r   r   _SOURCECODEr^  r_  exception_templatedictr  r   r   RuntimeErrorr   r   r   r  r  r2  rR   r_   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   