
    g                        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           	      v
   t        j                  |       t         j                  j                  d|d       t	        j
                         }d| v r|j                  ddd      }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       d| v r|j                  ddd	      }|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                  |
        d| v rg dg dg dg}|j                  ddd      j                  |d       g dg dg dg}|j                  ddd      j                  |d       g dg dg dg}|j                  ddd      j                  |d       d| v r{ G d  d!t              }|j                  d"#      }|j                  d	gg      }|j                  t!        d$d%&             |j#                  d	      \  }}t	        j$                  t'        d'            }t)        d(d)d*+      } |||d,-      }t+        t-                     }|j/                  |       t1        d.|d/d01      }|j/                  |       t3        j4                         j7                         }|xj8                  dz  c_        |xj8                  d	z  c_        t3        j:                         j7                         }|j8                  d d d2   |_        t3        j<                  ||      }t3        j>                  d      j7                         }|xj8                  d3z  c_        |j#                  d	d	d/d/4      \  }}||fD ]  }|\  }}tA        |gdd5d6d7d89      }|j                  ||jB                         |jE                  |       t        |dd5d6d7d89      }|j                  ||jB                         |jG                  |       |jI                  d:dg       |jK                  d:dg        t        d      }|j                  ddd      }|j                  ||       |jM                  d;       |jO                  d;       |jQ                  d;       tS        tT        jV                  d<tT        jV                        }|jY                  ||=       y )>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        |   |fi | t        | j                  d d       | _        | j                  j                  |       y )N)normorigin)super__init__r   get_window_extent
bbox_imageset_data)selfpathr9   kwargs	__class__s       ^/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/matplotlib/tests/test_determinism.pyr7   z4_save_figure.<locals>.PathClippedImagePatch.__init__H   sA     00"+**d#D((4    c                 $    t         |   d       y)zSimply ignore facecolor.noneN)r6   set_facecolor)r;   colorr>   s     r?   rC   z9_save_figure.<locals>.PathClippedImagePatch.set_facecolorN   s    %f-r@   c                     | j                   j                  | j                  | j                                | j                   j	                  |       t
        |   |       y N)r9   set_clip_path_pathget_transformdrawr6   )r;   rendererr>   s     r?   rJ   z0_save_figure.<locals>.PathClippedImagePatch.drawR   sB    --djj$:L:L:NO$$X.X&r@   rF   )__name__
__module____qualname____doc__r7   rC   rJ   __classcell__)r>   s   @r?   PathClippedImagePatchr2   @   s    5.' 'r@   rQ   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
   rG   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patternsrs   patternArQ   pxpimgarr	text_pathr0   	offsetboxaoexteriorinterior	clip_pathstarrow1row2row
collectionpatchaxr   s                                  r?   _save_figurer      s   GGCLLLGH
**,C
g~ooaA&"IQC"HS)QC"HS)QC"HS)QC"HS)QC"HS)
g~ooaA&aU1a[1aaS1WU1a[AB+,<h/ 	#LCMM'"	# g~	9-1a '''C	9-1a '''D	9-1a '''C
g~	'I 	'2 ___0yy1#6&89 \\!_
cjj);<=VT4	!)SS9#$5$78	Q<y$),.r &&(113QQ##%..0$--dd3++Hh?	%%a(113||Aqd|Ct$< 	"CHC'127s#OJ$$Y>z*dqFe$'s4E	3==9MM% LL"a!LL"a!	" 	aA	Aq	!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)r0   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 )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.
    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)	rq   r   r   
executableosenvironr   pytestskip)r   r   r   _plotsr0   s         r?   test_determinism_checkr      s    H 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    0 %	t G1
&	'"rzz " "26U$P
 QWPV  S==r@   )&rO   r   r   r   
matplotlibrj   r   rn   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r$j D$|5F&G	IVUD=!!> 5
 	<		r@   