ó
    {ñ:i¿  ã                   ó  • S r SSKrSSKJr  SSKJr  SSKJrJr  SSK	r	SSK
JrJr  SSKrSSKJrJr  SSKJr   " S	 S
\R&                  \R(                  5      rS r0 / 4S jr\\S.\l         " S S\5      rSS jrS rS rS rg)aø  
A role and directive to display mathtext in Sphinx
==================================================

The ``mathmpl`` Sphinx extension creates a mathtext image in Matplotlib and
shows it in html output. Thus, it is a true and faithful representation of what
you will see if you pass a given LaTeX string to Matplotlib (see
:ref:`mathtext`).

.. warning::
    In most cases, you will likely want to use one of `Sphinx's builtin Math
    extensions
    <https://www.sphinx-doc.org/en/master/usage/extensions/math.html>`__
    instead of this one. The builtin Sphinx math directive uses MathJax to
    render mathematical expressions, and addresses accessibility concerns that
    ``mathmpl`` doesn't address.

Mathtext may be included in two ways:

1. Inline, using the role::

     This text uses inline math: :mathmpl:`\alpha > \beta`.

   which produces:

     This text uses inline math: :mathmpl:`\alpha > \beta`.

2. Standalone, using the directive::

     Here is some standalone math:

     .. mathmpl::

         \alpha > \beta

   which produces:

     Here is some standalone math:

     .. mathmpl::

         \alpha > \beta

Options
-------

The ``mathmpl`` role and directive both support the following options:

fontset : str, default: 'cm'
    The font set to use when displaying math. See :rc:`mathtext.fontset`.

fontsize : float
    The font size, in points. Defaults to the value from the extension
    configuration option defined below.

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

The mathtext extension has the following configuration options:

mathmpl_fontsize : float, default: 10.0
    Default font size, in points.

mathmpl_srcset : list of str, default: []
    Additional image sizes to generate when embedding in HTML, to support
    `responsive resolution images
    <https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images>`__.
    The list should contain additional x-descriptors (``'1.5x'``, ``'2x'``,
    etc.) to generate (1x is the default and always included.)

é    N)ÚPath)Únodes)Ú	DirectiveÚ
directives)ÚConfigErrorÚExtensionError)Ú_apiÚmathtext)Úvalidate_float_or_Nonec                   ó   • \ rS rSrSrg)Ú
latex_mathéW   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    Ú_/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/matplotlib/sphinxext/mathmpl.pyr   r   W   s   † Úr   r   c                 ó`   • [         R                  " U [        R                  R                  5      $ ©N)r   Úchoicer
   ÚMathTextParserÚ_font_type_mapping)Úargs    r   Úfontset_choicer   [   s!   € Ü×Ò˜S¤(×"9Ñ"9×"LÑ"LÓMÐMr   c                 óò   • UR                  S5      nXS-   S n[        U5      n	X‰S'   UR                  SS5      U	S'   UR                  S[        R                  R
                  R                  5      U	S'   U	// 4$ )NÚ`é   éÿÿÿÿÚlatexÚfontsetÚcmÚfontsize)Úfindr   ÚgetÚsetupÚappÚconfigÚmathmpl_fontsize)
ÚroleÚrawtextÚtextÚlinenoÚinlinerÚoptionsÚcontentÚir"   Únodes
             r   Ú	math_roler5   _   sw   € à�‰�SÓ€AØ�a‘C˜ˆO€EÜ�gÓ€DØˆ�MØ—k‘k )¨TÓ2€Dˆ�OØ—{‘{ :Ü#(§9¡9×#3Ñ#3×#DÑ#DóF€DˆÑàˆ6�2ˆ:Ðr   ©r#   r%   c                   ó8   • \ rS rSrSrSrSrSrSr\	\
S.rS rSrg	)
ÚMathDirectiveém   zJ
The ``.. mathmpl::`` directive, as documented in the module's docstring.
Tr   Fr6   c                 ó0  • SR                  U R                  5      n[        U R                  5      nXS'   U R                  R                  SS5      US'   U R                  R                  S[        R                  R                  R                  5      US'   U/$ )NÚ r"   r#   r$   r%   )
Újoinr2   r   Ú
block_textr1   r'   r(   r)   r*   r+   )Úselfr"   r4   s      r   ÚrunÚMathDirective.runx   sy   € Ø—‘˜Ÿ™Ó%ˆÜ˜$Ÿ/™/Ó*ˆØˆW‰ØŸ,™,×*Ñ*¨9°dÓ;ˆˆY‰ØŸ<™<×+Ñ+¨JÜ,1¯I©I×,<Ñ,<×,MÑ,MóOˆˆZÑàˆvˆr   r   N)r   r   r   r   Ú__doc__Úhas_contentÚrequired_argumentsÚoptional_argumentsÚfinal_argument_whitespacer   r   Úoption_specr?   r   r   r   r   r8   r8   m   s2   † ñð €KØÐØÐØ %ÐØ,Ø5ñ7€Kõr   r8   c                 óø   • [         R                  " X#S.5          [        R                  " SU  S3XSS9nS S S 5        U$ ! [         a    [
        R                  " SU  35        Sn N1f = f! , (       d  f       W$ = f)N)zmathtext.fontsetz	font.sizeÚ$Úpng)ÚdpiÚformatz!Could not render math expression r   )ÚmplÚ
rc_contextr
   Úmath_to_imageÚ	Exceptionr	   Úwarn_external)r"   Úfilenamer#   r%   rJ   Údepths         r   Ú	latex2pngrS   ƒ   s   € Ü	�Š¨WÑLÕ	Mð	Ü×*Ò*Ø�E�7˜!�˜h¸ñ?ˆE÷ 
Nð €Løô ó 	Ü×ÒÐ!BÀ5À'ÐJÔKØŠEð	ú÷	 
NÔ	Mð €Lús&   ™A*›?¿%A'Á$A*Á&A'Á'A*Á*
A9c                 ó  • [        U R                  [        R                  5      nU S   nU S   nU S   nSR	                  [
        R                  " U U U 3R                  5       SS9R                  5       SS  5      n[        [        R                  R                  R                  SS	5      nUR                  S
S
S9  Xv S3-  n[        X8XES9n	/ n
[        R                  R                   R"                   Hs  nU SUR%                  SS5       S3n[        X7U-  XES['        US S 5      -  S9  U
R)                  [        R                  R                  R*                   SU SU 35        Mu     U
(       a@  S[        R                  R                  R*                   SU S3SR-                  U
5      -   S-   n
U(       a  SnOSnU(       a  U	S:w  a	  SU	S-   -  nOSnS[        R                  R                  R*                   SU S U
 U U S!3	$ )"Nr"   r#   r%   zmath-{}F)ÚusedforsecurityiöÿÿÿÚ_imagesÚmathmplT)ÚparentsÚexist_okz.png)r%   Ú-Ú.Ú_éd   r!   )r%   rJ   z	/mathmpl/Ú zsrcset="z.png, z, z" r;   zclass="center" r   z)style="position: relative; bottom: -%dpx"r    z
<img src="z.png" z/>)Ú
isinstanceÚparentr   ÚTextElementrK   ÚhashlibÚsha256ÚencodeÚ	hexdigestr   r(   r)   ÚbuilderÚoutdirÚmkdirrS   r*   Úmathmpl_srcsetÚreplaceÚfloatÚappendÚimgpathr<   )r4   ÚsourceÚinliner"   r#   r%   ÚnameÚdestdirÚdestrR   ÚsrcsetÚsizerQ   ÚclsÚstyles                  r   Ú
latex2htmlrw   �   s  € Ü˜Ÿ™¤U×%6Ñ%6Ó7€FØ�‰M€EØ�9‰o€GØ�JÑ€HØ×ÑÜ�ŠØˆg�g�Y˜x˜jÐ)×0Ñ0Ó2Ø!ñ	
÷ ‰)‹+�c�dð	ó€Dô ”5—9‘9×$Ñ$×+Ñ+¨Y¸	ÓB€GØ‡M�M˜$¨€MÑ.à�v˜T�]Ñ"€DÜ�e 7Ñ>€Eà€FÜ—	‘	× Ñ ×/Ô/ˆØ�V˜1˜TŸ\™\¨#¨sÓ3Ð4°DÐ9ˆÜ�% 8Ñ+¨WØœE $ s¨ )Ó,Ñ,ò	.à�‰Ü�y‰y× Ñ ×(Ñ(Ð)¨°8°*¸A¸d¸VÐDö	Fñ	 0ö ØœUŸY™Y×.Ñ.×6Ñ6Ð7°yÀÀÀfÐMØ—)‘)˜FÓ#ñ$Ø&*ñ+ˆö Ø‰àˆÞ�%˜1“*Ø;¸uÀq¹yÑI‰àˆàœŸ™×*Ñ*×2Ñ2Ð3°9¸T¸Fð CØˆx˜�u˜U˜G 2ð'ð (r   c                 óà   • [        U R                  R                  5       H-  u  p#US   S:X  a   [        US S 5        M  [        SU< S35      e   g ! [         a    [        SU< S35      ef = f)Nr!   Úxz,Invalid value for mathmpl_srcset parameter: ze. Must be a list of strings with the multiplicative factor followed by an "x".  e.g. ["2.0x", "1.5x"])Ú	enumerater*   ri   rk   Ú
ValueErrorr   )r)   r*   r3   rt   s       r   Ú_config_initedr|   ¸   s—   € ä˜SŸZ™Z×6Ñ6Ö7‰ˆØ�‰8�s‹?ðIÜ�d˜3˜B�iÖ ô Ø>¸t¹hð GDð DóEð Eò 8øô ó IÜ!ØBÀ4Á(ð KHð HóIð IðIús   ¯AÁA-c                 ó  • U [         l        U R                  SSS5        U R                  S/ S5         U R                  S[        5        S nS	 nS
 nS nU R                  [        X4X44S9  U R                  S[        5        U R                  S[        5        [        R                  S:  a,  U R                  S[        5        U R                  S[        5        SSS.nU$ ! [
         a    U R                  SS 5         Nµf = f)Nr+   g      $@Tri   zconfig-initedzenv-updatedc                 ó   • [        U S 5      $ r   )r|   )r)   Úenvs     r   Ú<lambda>Úsetup.<locals>.<lambda>Ñ   s   € ´NÀ3ÈÔ4Mr   c                 ó~   • U R                   R                  S   nU R                  R                  [	        X5      5        g )Nrn   )ÚdocumentÚ
attributesÚbodyrl   rw   )r>   r4   rn   s      r   Úvisit_latex_math_htmlÚ$setup.<locals>.visit_latex_math_htmlÔ   s-   € Ø—‘×)Ñ)¨(Ñ3ˆØ�	‰	×Ñœ DÓ1Õ2r   c                 ó   • g r   r   ©r>   r4   s     r   Údepart_latex_math_htmlÚ%setup.<locals>.depart_latex_math_htmlØ   ó   € Ør   c                 óà   • [        UR                  [        R                  5      nU(       a"  U R                  R                  SUS   -  5        g U R                  R                  SUS   S/5        g )Nz$%s$r"   z\begin{equation}z\end{equation})r_   r`   r   ra   r…   rl   Úextend)r>   r4   ro   s      r   Úvisit_latex_math_latexÚ%setup.<locals>.visit_latex_math_latexÜ   sZ   € Ü˜DŸK™K¬×):Ñ):Ó;ˆÞØ�I‰I×Ñ˜V d¨7¡mÑ3Õ4à�I‰I×ÑÐ1Ø" 7™mØ/ð1õ 2r   c                 ó   • g r   r   r‰   s     r   Údepart_latex_math_latexÚ&setup.<locals>.depart_latex_math_latexå   rŒ   r   )Úhtmlr"   rW   )r    é   Úmath)Úparallel_read_safeÚparallel_write_safe)r(   r)   Úadd_config_valueÚconnectr|   r   Úadd_noder   Úadd_roler5   Úadd_directiver8   ÚsphinxÚversion_info)r)   r†   rŠ   r�   r’   Úmetadatas         r   r(   r(   Ê   s÷   € Ø„E„IØ×ÑÐ+¨T°4Ô8Ø×ÑÐ)¨2¨tÔ4ðOØ�‰�O¤^Ô4ò
3òò2òð ‡L�L”Ø,ÐEØ.ÐHð ñ Jð ‡L�L�œIÔ&Ø×Ñ�i¤Ô/Ü×Ñ˜VÓ#Ø�‰�VœYÔ'Ø×Ñ˜&¤-Ô0à&*À4ÑH€HØ€OøôE ó OØ�‰�MÑ#MÖNðOús   ³C ÃC?Ã>C?)r$   é
   r]   )rA   rb   Úpathlibr   Údocutilsr   Údocutils.parsers.rstr   r   rž   Úsphinx.errorsr   r   Ú
matplotlibrL   r	   r
   Úmatplotlib.rcsetupr   ÚGeneralÚElementr   r   r5   r1   r8   rS   rw   r|   r(   r   r   r   Ú<module>rª      s…   ðñFóP Ý å ß 6Û ß 5ã ß %Ý 5ô	�—‘ §¡ô 	òNð
  "ô	ð !/Ø!7ñ9€	Ô ô�Iô ô,ò&(òREó$(r   