
    P/Ph                        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j!        "                    ddddddd ej#        dddeeg          dd ej#        ddde          g
          d             Z$ej!        "                    d d!d"g          d#             Z%dS )$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mhippdfFc           	         t          j        |           t           j                            d|d           t	          j                    }d| v r|                    ddd          }t          d          }|                    |dgdz  d           |                    |d	gdz  d
           |                    |dgdz  d           |                    |dgdz  d           |                    |dgdz  d           d| v r|                    ddd	          }|	                    t          dd          t          dd                    |	                    t          dd          dgdz  t          dd                    z   }|
                    g d           d}t          ||          D ]\  }	}
|	                    |
           d| v rg dg dg dg}|                    ddd                              |d           g dg dg dg}|                    ddd                              |d           g dg dg dg}|                    ddd                              |d           d| v r G d  d!t                    }|                    d"#          }|                    d	gg          }|                    t!          d$d%&                     |                    d	          \  }}t	          j        t'          d'                    }t)          d(d)d*+          } |||d,-          }t+          t-                                }|                    |           t1          d.|d/d01          }|                    |           t3          j                                                    }|xj        dz  c_        |xj        d	z  c_        t3          j                                                    }|j        d d d2         |_        t3          j        ||          }t3          j        d                                          }|xj        d3z  c_        |                    d	d	d/d/4          \  }}||fD ]}|\  }}tA          |gdd5d6d7d89          }|                    ||j!                   |"                    |           t          |dd5d6d7d89          }|                    ||j!                   |#                    |           |$                    d:dg           |%                    d:dg           t          d          }|                    ddd          }|                    ||           |&                    d;           |'                    d;           |(                    d;           tS          tT          j+        d<tT          j+                  }|,                    ||=           d S )>Nasdf)zsvg.hashsaltztext.usetexm      
   D)marker   x   ^   H   vh)bottom)g      ?g      @g      @g      @)-+r   \*oO.i)r   r   r   )r   r   r   )r   r   r   nearest)interpolation)r   r   r   bilinear)r   r   r   bicubicpc                   8     e Zd ZdZ fdZ fdZd fd	Z xZS )+_save_figure.<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                      j        |fi | t          | j        d d           | _        | j                            |           d S )N)normorigin)super__init__r   get_window_extent
bbox_imageset_data)selfpathr:   kwargs	__class__s       a/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/matplotlib/tests/test_determinism.pyr8   z4_save_figure.<locals>.PathClippedImagePatch.__init__H   sa      00000"+*d#D #D #D((44444    c                 J    t                                          d           dS )zSimply ignore facecolor.noneN)r7   set_facecolor)r<   colorr?   s     r@   rD   z9_save_figure.<locals>.PathClippedImagePatch.set_facecolorN   s!    %%f-----rA   Nc                     | j                             | j        |                                            | j                             |           t                                          |           d S N)r:   set_clip_path_pathget_transformdrawr7   )r<   rendererr?   s     r@   rK   z0_save_figure.<locals>.PathClippedImagePatch.drawR   s[    --dj$:L:L:N:NOOO$$X...X&&&&&rA   rG   )__name__
__module____qualname____doc__r8   rD   rK   __classcell__)r?   s   @r@   PathClippedImagePatchr3   @   sy         5 5 5 5 5. . . . .' ' ' ' ' ' ' ' ' 'rA   rR   polar)
projection)r   r   gioT?)radiuszgrace_hopper.jpg)r   r   z!?   )sizek)ecz
upper leftTg?)locchildframeon	borderpadg@)sharexshareyblueredgffffff?r(   )lw	edgecolor	facecoloralphahatchzA string $1+2+\sigma$buffer)format)-mplusercParamsupdatepltfigureadd_subplotrangeplotbar
set_xtickszip	set_hatchimshowr
   rH   r	   subplotsimreadr   r   r   r   
add_artistr   r   unit_rectangledeepcopyverticesunit_circlemake_compound_pathunit_regular_starr   	transDataadd_collection	add_patchset_xlimset_ylim	set_title
set_xlabel
set_ylabelgetattrsysstdoutsavefig)objectsfmtusetexfigax1r   ax2barspatternsrt   patternArR   pxpimgarr	text_pathr1   	offsetboxaoexteriorinterior	clip_pathstarrow1row2row
collectionpatchaxr   s                                  r@   _save_figurer      s   GCLLLLGGHHH
*,,C
g~~ooaA&&"IIQC"HS)))QC"HS)))QC"HS)))QC"HS)))QC"HS)))
g~~ooaA&&aU1a[[11aaS1WU1a[[AAB+++,,,<h// 	# 	#LCMM'""""
g~~YY			999-1a  '''CCCYY			999-1a  '''DDDYY			999-1a  '''CCC
g~~	' 	' 	' 	' 	'I 	' 	' 	'2 ___00yy1#6&888999 \\!__
cj);<<==VT444	!!)SS999#$5$7$788	Q<y$),. . .r &((1133QQ#%%..00$-ddd3+Hh??	%a((1133||Aqd|CCt$< 	" 	"CHC'127s#O O OJ$$Y>>>z***dqFe$'s4 4 4E	3=999MM%   LL"a!!!LL"a!!!!aA	Aq	!	!BGGAqMMMLL)***MM*+++MM*+++SZ3:66FKKsK#####rA   zobjects, fmt, usetex) r   F)r   r   F)r#   r   F)r,   r   F)r   r   F)r   psFr   T)marks)r1   svgF)r   r   Fr   c                       fdt          d          D             }|dd         D ]9}dk    r#r!||d         k    rt          j        d           +||d         k    sJ :dS )aR  
    Output three times the same graphs and checks 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.
    c                     g | ]D}t          t          j        d dddd dgi t          j        ddddd	d	
          j        ES )-R-czHfrom matplotlib.tests.test_determinism import _save_figure;_save_figure(z, )	946684800AggSOURCE_DATE_EPOCH
MPLBACKENDFT)envtextcapture_outputcheckr   r   
executableosenvironr   ).0_r   r   r   s     r@   
<listcomp>z*test_determinism_check.<locals>.<listcomp>   s     	 	 	  	#^T4=$= =*-= =39= = =>&2: &K$& & &t4	9 	9 	9 :@	 	 	rA   r   r   Nr   r   z+failed, maybe due to ghostscript timestamps)rr   pytestskip)r   r   r   plotsr1   s   ```  r@   test_determinism_checkr      s    8	 	 	 	 	 	 q	 	 	E 122Y ! !$;;6;E!H}}IJJJa=====! !rA   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 dS )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   Nr   )r   stringbufs      r@   "test_determinism_source_date_epochr      s    0 %	t
& 
& 
& 
&	'"rz " " " "26U$P P P
 QW  S======rA   )&rP   r   r   r   
matplotlibrk   r   ro   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    rA   r@   <module>r      s    
			 



      $ $ $ $ $ $ , , , , , , 1 1 1 1 1 1 & & & & & & C C C C C C C C 0 0 0 0 0 0 0 0             9 9 9 9 9 9 G G G G G G G G ! ! ! ! $ $ $ $ $ $ 3 3 3 3 3 3r$ r$ r$ r$j D$|5F&G	I 	I 	IVUD=== ! ! !> 5
 	<	 	 	 	  rA   