Ë
    íÍ:j!  ã                   ó¼  — d Z ddlZddlZddlZddl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mZ ddlmZmZ dd	lmZ dd
lmZ ddlmZmZ ddlZddlmZ ddlmZ dd„Z ejB                  jE                  ddddddd ejF                  dddeeg¬«      dd ejF                  ddde¬«      g
«      d„ «       Z$ejB                  jE                  ddd g«      d!„ «       Z%y)"z
Test output reproducibility.
é    N)Úpyplot)Úget_sample_data)ÚPathCollection)Ú	BboxImage)ÚAnchoredOffsetboxÚAuxTransformBox)ÚCircleÚ	PathPatch)ÚPath)Úsubprocess_run_for_testing)Úneeds_ghostscriptÚneeds_usetex)ÚTextPath)ÚIdentityTransformÚmhipc                 ó>  — t        j                  |«       t         j                  j                  d|dœ«       d„ }d„ }d„ }d„ }t	        | «      dz   }t        j                  dd	|z  f¬
«      }t        |j                  |d¬«      j                  «      }	|j                  d¬«       d| v r |t        |	«      «       d| v r |t        |	«      «       d| v r |t        |	«      «       d| v r |t        |	«      «       t        d«      }
t        |	«      j                  «       }|j                  |
|
«       |j                  d«       |j!                  d«       |j#                  d«       t%        t&        j(                  dt&        j(                  «      }|j+                  ||¬«       y )NÚasdf)zsvg.hashsaltztext.usetexc                 ó*  — | j                  «       }t        d«      }|j                  |dgdz  d¬«       |j                  |dgdz  d¬«       |j                  |dgdz  d¬«       |j                  |d	gdz  d
¬«       |j                  |dgdz  d¬«       y )Né
   é   ÚD)Úmarkeré   Úxé   ú^é   ÚHé   Úv)Úadd_subplotÚrangeÚplot)ÚfigÚaxr   s      úv/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/matplotlib/tests/test_determinism.pyÚplot_markersz"_save_figure.<locals>.plot_markers   s�   € à�_‰_ÓˆÜ�"‹IˆØ
�‰��A�3˜‘8 CˆÔ(Ø
�‰��A�3˜‘8 CˆÔ(Ø
�‰��A�3˜‘8 CˆÔ(Ø
�‰��A�3˜‘8 CˆÔ(Ø
�‰��A�3˜‘8 CˆÕ(ó    c           	      ó>  — | j                  «       }|j                  t        dd«      t        dd«      «      |j                  t        dd«      dgdz  t        dd«      ¬«      z   }|j                  g d¢«       d}t	        ||«      D ]  \  }}|j                  |«       Œ y )Nr   r   é   r   ©Úbottom)g      ø?g      @g      @g      @)ú-ú+r   ú\Ú*ÚoÚOú.)r!   Úbarr"   Ú
set_xticksÚzipÚ	set_hatch)r$   Úax2ÚbarsÚpatternsr4   Úpatterns         r&   Ú
plot_hatchz _save_figure.<locals>.plot_hatch'   sŒ   € à�o‰oÓˆØ—‘œ˜a ›¤U¨1¨a£[Ó1Ø—‘œ˜a › a S¨1¡W´U¸1¸a³[�ÓAñBˆà�‰Ò+Ô,à<ˆÜ  hÓ/ò 	#‰LˆC�Ø�M‰M˜'Õ"ñ	#r(   c                 óô   — | j                  dddd¬«      }g d¢g d¢g d¢g}|d   j                  |d	¬
«       g d¢g d¢g d¢g}|d   j                  |d¬
«       g d¢g d¢g d¢g}|d   j                  |d¬
«       y )Nr   r   T)ÚsharexÚsharey)r   r   r   )r   r   r   )r   r   r   r   Únearest)Úinterpolation)r   r   r   Úbilinear)r   r   r   r   Úbicubic)ÚsubplotsÚimshow)r$   ÚaxsÚAs      r&   Ú
plot_imagez _save_figure.<locals>.plot_image2   sx   € Ø�l‰l˜1˜a¨°TˆlÓ:ˆâš	¢9Ð-ˆØˆA‰�‰�a yˆÔ1Úš	¢9Ð-ˆØˆA‰�‰�a zˆÔ2Úš	¢9Ð-ˆØˆA‰�‰�a yˆÕ1r(   c           
      ó@  —  G d„ dt         «      }| j                  dd«      }|d   j                  d¬«      }|j                  dgg«      }|j	                  t        d	d
¬«      «       |d   j                  «       }t        j                  t        d«      «      }t        ddd¬«      } |||d¬«      }t        t        «       «      }	|	j                  |«       t        d|	dd¬«      }
|j                  |
«       t        j                  «       j!                  «       }|xj"                  dz  c_        |xj"                  dz  c_        t        j$                  «       j!                  «       }|j"                  d d d…   |_        t        j&                  ||«      }t        j(                  d«      j!                  «       }|xj"                  dz  c_        |d   j+                  ddddt-        dd¬«      ¬«      \  }}||fD ]ª  }|\  }}t/        |gdddd d!¬"«      }|j	                  ||j0                  «       |j3                  |«       t        |dddd d!¬"«      }|j	                  ||j0                  «       |j5                  |«       |j7                  d#dg«       |j9                  d#dg«       Œ¬ y )$Nc                   ó8   ‡ — e Zd ZdZˆ fd„Zˆ fd„Zdˆ fd„	Zˆ xZS )ú?_save_figure.<locals>.plot_paths.<locals>.PathClippedImagePatchzã
            The given image is used to draw the face of the patch. Internally,
            it uses BboxImage whose clippath set to the path of the patch.

            FIXME : The result is currently dpi dependent.
            c                 ó–   •— t        ‰| �  |fi |¤Ž t        | j                  d d ¬«      | _        | j                  j                  |«       y )N)ÚnormÚorigin)ÚsuperÚ__init__r   Úget_window_extentÚ
bbox_imageÚset_data)ÚselfÚpathrR   ÚkwargsÚ	__class__s       €r&   rP   zH_save_figure.<locals>.plot_paths.<locals>.PathClippedImagePatch.__init__F   sA   ø€ Ü‘Ñ  Ñ0¨Ò0Ü"+Ø×*Ñ*°¸dô#D�”à—‘×(Ñ(¨Õ4r(   c                 ó$   •— t         ‰| �  d«       y)zSimply ignore facecolor.ÚnoneN)rO   Úset_facecolor)rT   ÚcolorrW   s     €r&   rZ   zM_save_figure.<locals>.plot_paths.<locals>.PathClippedImagePatch.set_facecolorL   s   ø€ ä‘Ñ% fÕ-r(   c                 óÂ   •— | j                   j                  | j                  | j                  «       «       | j                   j	                  |«       t
        ‰| �  |«       y ©N)rR   Úset_clip_pathÚ_pathÚget_transformÚdrawrO   )rT   ÚrendererrW   s     €r&   ra   zD_save_figure.<locals>.plot_paths.<locals>.PathClippedImagePatch.drawP   sB   ø€ à—‘×-Ñ-¨d¯j©j¸$×:LÑ:LÓ:NÔOØ—‘×$Ñ$ XÔ.Ü‘‘˜XÕ&r(   r]   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rP   rZ   ra   Ú__classcell__)rW   s   @r&   ÚPathClippedImagePatchrK   >   s   ø„ ñô5ô.÷'ñ 'r(   rh   r   r   r   Úpolar)Ú
projectionr   )r   r   gioð…ÉTÕ?)Úradiuszgrace_hopper.jpg)r   r   z!?é–   )ÚsizeÚk)Úecz
upper leftTgš™™™™™É?)ÚlocÚchildÚframeonÚ	borderpadr   éÿÿÿÿr*   gÍÌÌÌÌÌ@)ÚhspaceÚwspace)r>   r?   Úgridspec_kwr   ÚblueÚredgffffffæ?r0   )ÚlwÚ	edgecolorÚ	facecolorÚalphaÚhatchéýÿÿÿ)r
   Ú
subfiguresr!   rE   r^   r	   ÚpltÚimreadr   r   r   r   Ú
add_artistr   r   Úunit_rectangleÚdeepcopyÚverticesÚunit_circleÚmake_compound_pathÚunit_regular_starrD   Údictr   Ú	transDataÚadd_collectionÚ	add_patchÚset_xlimÚset_ylim)r$   rh   ÚsubfigsÚpxÚpimgr%   ÚarrÚ	text_pathÚpÚ	offsetboxÚaoÚexteriorÚinteriorÚ	clip_pathÚstarÚrow1Úrow2ÚrowÚax1r8   Ú
collectionÚpatchs                         r&   Ú
plot_pathsz _save_figure.<locals>.plot_paths<   s`  € ô	'¤Iô 	'ð0 —.‘.  AÓ&ˆð �Q‰Z×#Ñ#¨wÐ#Ó7ˆØ�y‰y˜1˜#˜ÓˆØ×Ñœ6 &°Ô8Ô9ð �Q‰Z×#Ñ#Ó%ˆÜ�j‰jœÐ);Ó<Ó=ˆÜ˜V T°Ô4ˆ	Ù! )¨S°SÔ9ˆÜ#Ô$5Ó$7Ó8ˆ	Ø×Ñ˜QÔÜ <°yÈ$Ø),ô.ˆà
�‰�bÔô ×&Ñ&Ó(×1Ñ1Ó3ˆØ×Ò˜QÑÕØ×Ò˜QÑÕÜ×#Ñ#Ó%×.Ñ.Ó0ˆØ$×-Ñ-©d°¨dÑ3ˆÔÜ×+Ñ+¨H°hÓ?ˆ	ä×%Ñ% aÓ(×1Ñ1Ó3ˆØ�Š˜Ñ�à˜q‘z×*Ñ*¨1¨a¸ÀTÜ7;À1ÈQÔ7Oð +ó Q‰ˆˆtà˜$�<ò 	"ˆCØ‰HˆC�Ü'¨¨°1ÀØ27¸sÈ#ôOˆJà×$Ñ$ Y°·±Ô>Ø×Ñ˜zÔ*ä˜d q°FÀeØ$'¨sô4ˆEà×Ñ 	¨3¯=©=Ô9Ø�M‰M˜%Ô à�L‰L˜"˜a˜Ô!Ø�L‰L˜"˜a˜Õ!ñ	"r(   r   é   r   )ÚfigsizeF)Úsqueezeg333333Ã?r+   ÚmÚhÚir•   r   zA string $1+2+\sigma$Úbuffer)Úformat)ÚmplÚuseÚrcParamsÚupdateÚlenr�   ÚfigureÚiterr€   ÚflatÚsubplots_adjustÚnextr"   r!   r#   Ú	set_titleÚ
set_xlabelÚ
set_ylabelÚgetattrÚsysÚstdoutÚsavefig)ÚobjectsÚfmtÚusetexr'   r<   rH   r¢   Únfigsr$   r�   r   r%   rº   s                r&   Ú_save_figurerÀ      sO  € Ü‡G�GˆC„LÜ‡L�L×Ñ¨ÀÑGÔHò)ò	#ò2òF"ôP �‹L˜1Ñ€EÜ
�*‰*˜a  U¡˜^Ô
,€CÜ�3—>‘> %°�>Ó7×<Ñ<Ó=€GØ×Ñ˜tÐÔ$à
ˆg�~Ù”T˜'“]Ô#Ø
ˆg�~Ù”4˜“=Ô!Ø
ˆg�~Ù”4˜“=Ô!Ø
ˆg�~Ù”4˜“=Ô!äˆa‹€AÜ	ˆg‹×	"Ñ	"Ó	$€BØ‡G�GˆAˆq„MØ‡L�LÐ)Ô*Ø‡M�MÐ*Ô+Ø‡M�MÐ*Ô+ä”S—Z‘Z ¬3¯:©:Ó6€FØ‡K�K�˜s€KÕ#r(   zobjects, fmt, usetex)Ú ÚpdfF)r¦   rÂ   F)r§   rÂ   F)r¨   rÂ   F)r   rÂ   F)r   ÚpsFrÃ   T)Úmarks)r•   ÚsvgF)r   rÅ   FrÅ   c                 óD  — t        d«      D �cg c]M  }t        t        j                  ddd| ›d|›d|› d�gi t        j
                  ¥ddd	œ¥d
dd¬«      j                  ‘ŒO }}|dd D ]2  }|dk(  r!|r||d   k7  sŒt        j                  d«       Œ)||d   k(  rŒ2J ‚ yc c}w )aL  
    Output the same graph three times and check that the outputs are exactly the same.

    Parameters
    ----------
    objects : str
        Objects to be included in the test document: 'm' for markers, 'h' for
        hatch patterns, 'i' for images, and 'p' for paths.
    fmt : {"pdf", "ps", "svg"}
        Output format.
    r   ú-Rú-czHfrom matplotlib.tests.test_determinism import _save_figure;_save_figure(z, ú)Ú	946684800ÚAgg©ÚSOURCE_DATE_EPOCHÚ
MPLBACKENDFT)ÚenvÚtextÚcapture_outputÚcheckr   NrÃ   r   z+failed, maybe due to ghostscript timestamps)	r"   r   r¹   Ú
executableÚosÚenvironrº   ÚpytestÚskip)r¼   r½   r¾   Ú_Úplotsr•   s         r&   Útest_determinism_checkrÚ   �   sÖ   € ôD �q“ö	ð ô 	#Ü�^‰^˜T 4ðØ$˜K r¨#¨°°6°(¸!ð=ð>ð&”2—:‘:ð &°KØ$ò&à t°4ô	9÷ :@¹ñ	@ð	€Eð 	ð �1�2ˆYò !ˆØ�$Š;™6Ø�E˜!‘H‹}Ü—‘ÐIÕJà˜˜a™“=Ð �=ñ!ùò	s   ŽABzfmt, string)rÂ   s!   /CreationDate (D:20000101000000Z))rÃ   s(   %%CreationDate: Sat Jan 01 00:00:00 2000c                 óš   — t        t        j                  ddd| ›d�gi t        j                  ¥dddœ¥dd	d¬
«      j
                  }||v sJ ‚y)a˜  
    Test SOURCE_DATE_EPOCH support.

    Output a document with the environment variable SOURCE_DATE_EPOCH set to
    2000-01-01 00:00 UTC and check that the document contains the timestamp that
    corresponds to this date (given as an argument).

    Parameters
    ----------
    fmt : {"pdf", "ps", "svg"}
        Output format.
    string : bytes
        Timestamp string for 2000-01-01 00:00 UTC.
    rÇ   rÈ   zMfrom matplotlib.tests.test_determinism import _save_figure; _save_figure('', rÉ   rÊ   rË   rÌ   TF)rÏ   rÑ   rÐ   rÒ   N)r   r¹   rÓ   rÔ   rÕ   rº   )r½   ÚstringÚbufs      r&   Ú"test_determinism_source_date_epochrÞ   É   sl   € ô2 %Ü	�‰˜˜tðØ ˜G 1ð
&ð	'ð"Œr�z‰zð "°Ø ò"Ø26¸UÈ$ôP÷
 QWÑPVð ð �S‰=Ð‰=r(   )&rf   rÔ   r¹   rÖ   Ú
matplotlibr«   r   r�   Úmatplotlib.cbookr   Úmatplotlib.collectionsr   Úmatplotlib.imager   Úmatplotlib.offsetboxr   r   Úmatplotlib.patchesr	   r
   Úmatplotlib.pathr   Úmatplotlib.testingr   Úmatplotlib.testing._markersr   r   Úmatplotlib.testing.compareÚmatplotlib.textr   Úmatplotlib.transformsr   rÀ   ÚmarkÚparametrizeÚparamrÚ   rÞ   © r(   r&   ú<module>rï      sç   ðñó 
Û 
ã ã Ý $Ý ,Ý 1Ý &ß Cß 0Ý  Ý 9ß GÛ !Ý $Ý 3óA$ðH ‡�×ÑØØØØØØØØˆ�‰�V˜T 4°Ð>OÐ/PÔQØØØˆ�‰�V˜U D°Ô=ðóñ!óð!ð< ‡�×ÑØØ5ð
 	<ðó	ñó	ñr(   