
    ^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      l/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/matplotlib/tests/test_determinism.pyplot_markersz"_save_figure.<locals>.plot_markers   s    __"I
A38C(
A38C(
A38C(
A38C(
A38C(    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    ooaU1a[1aaS1WU1a[AB+,<h/ 	#LCMM'"	#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    ll1aTl:	9-Aay1	9-Aaz2	9-Aay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    --djj$: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   gioT?)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& QZ##w#7yy1#6&89 QZ##%jj);<=VT4	!)SS9#$5$78	Q<y$),.
b &&(113QQ##%..0$--dd3++Hh?	%%a(113qz**1aT7;1Q7O + Qt$< 	"CHC'127s#OJ$$Y>z*dqFe$'s4E	3==9MM% LL"a!LL"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   GGCLLLGH)	#2F"P L1E
**aU^
,C3>>%>7<<=Gt$
g~T']#
g~4=!
g~4=!
g~4=!aA	g	"	"	$BGGAqMLL)*MM*+MM*+SZZ3::6FKKsK#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	  	#^^T4$Kr#6(!=>&2:: &K$&t4	9 :@	@	E 	 12Y !$;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 G1
&	'"rzz " "26U$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 VT4>O/PQVUD=!!< 5
 	<		r(   