
    G8c%                        d dl mZ d dlmZ d dlZd dlZd dlZd dlZd dlm	Z	m
Z
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Zd dlmZ ej:                  j=                  d
      ej:                  j?                  dddg      ej:                  j?                  dddi fddddifddddifddddifddi fddddifddddifgg d      d                      Z d Z!eed               Z" edg      d        Z#e edg      d                Z$d! Z%ed"        Z&ed#        Z'ed$        Z( ed%g      d&        Z) ed'g      d(        Z* ed)g      d*        Z+ edg+      d,        Z,ed-        Z- ed.gd/0      d1        Z.ej:                  j?                  d2d3d4g      d5        Z/d6 Z0d7 Z1d8 Z2 ed9gd:;      d<        Z3 ed=gd>;      d?        Z4y)@    )Counter)PathN)cbookpatheffectsfont_manager)MatplotlibDeprecationWarning)Figure)Ellipse)needs_ghostscriptneeds_usetex)check_figures_equalimage_comparison   )rerunsorientationportrait	landscapezformat, use_log, rcParamspsFps.usedistillerghostscriptxpdftext.usetexTeps	ps.useafm)r   zps with distiller=ghostscriptzps with distiller=xpdfzps with usetexr   zeps afmzeps with usetex)idsc                    t         j                  j                  |       t        j                         \  }}t        j                         5 }t        j                         5 }|r|j                  d       |j                  ddgddg       d}t         j                  d   s|dz  }|j                  |       g }	|j                  d      r|	j                  t         j                         |j                  d      r|	j                  t               |j                  d      r|	j                  t               	 |j!                  || |	       |j!                  || |	       |j*                  rJ |j*                  rJ |j-                         j/                  d
      }|j-                         }t1        j2                  dd|      }t1        j2                  dd|      }||j5                  dd      k(  sJ 	 d d d        d d d        y # t#        |	      $ r(}
t%        j&                  t)        |
             Y d }
~
d }
~
ww xY w# 1 sw Y   KxY w# 1 sw Y   y xY w)Nlog      u	   Déjà vur   u    −€r   r   )formatr   asciis   (?<=
%%CreationDate: ).*    s   
   
)mplrcParamsupdatepltsubplotsioStringIOBytesIO
set_yscaleplot	set_titlegetappendExecutableNotFoundErrorRuntimeErrorr   savefigtuplepytestskipstrclosedgetvalueencoderesubreplace)r    use_logr%   r   figaxs_bufb_buftitleallowable_exceptionsexcs_valb_vals                B/usr/lib/python3/dist-packages/matplotlib/tests/test_backend_ps.pytest_savefig_to_stringiorI      s   ( LL!llnGC	 "6% "6MM% 
AA||M*33E
U!<<)* ''(C(CD<<& ''5<<$ ''(DE	"KKf+KFKKf+KF <<<< ''0 
 3S%@3S%@gu5555E"6 "6 "6( )* 	"KKC!!	")"6 "6 "6 "6sP   I CH74(G>BH7-I>H4H/*H7/H44H77I 	<IIc                  "   t        j                  dd      gt        j                  d<   t	        j
                         \  } }|j                  g d       t        j                         5 }| j                  |d       d d d        y # 1 sw Y   y xY w)N   w)	linewidth
foregroundzpath.effects)r   r   r   r   r    )
r   
withStroker$   r%   r'   r(   r-   r)   r+   r3   )r?   r@   r   s      rH   test_patheffectsrQ   Q   sm    s;$=CLL llnGCGGI	 %Bt$% % %s   (BBc                 `   t        | d      }|j                          t        j                  t        t        |            5  dt        j                  d<   t        j                  g d       t        j                  d       t        j                  |dz  d	       d d d        y # 1 sw Y   y xY w)
Nzshort-1)tempdirTr   )r   r   r   rK   z\textbf{time} (s)ztex_demo.epsr   rO   )r   mkdirr   _setattr_cmtempfiler7   r$   r%   r'   r-   xlabelr3   )tmpdirbase_tempdirs     rH   test_tilde_in_tempfilenamerZ   Z   s     	*L 
		8S->	? @&*]#

'(L>1$?@ @ @s   AB$$B-z	empty.epsc                      t        j                         \  } }|j                          |j                  ddgdd       |j	                  ddddd       y )Nr   r   rcoloralpha      ?foo)r'   r(   set_axis_offr-   textr?   r@   s     rH   test_transparencyre   m   sG    llnGCOOGGQF#QG'GGBEAG.r"   c                      dt         j                  d<   t        j                         \  } }|j	                          |j                  ddgdd       |j                  ddddd       y )	NTr   r   r   r\   r]   r`   ra   )r$   r%   r'   r(   rb   r-   rc   rd   s     rH   test_transparency_texrg   u   sW     #'CLLllnGCOOGGQF#QG'GGBEAG.r"   c            	      P   t        j                         \  } }t        j                         5 }| j	                  |d       |j                         }d d d        t        j                  dt        j                        }|sJ t        j                  d|t        j                        }|sJ t        dd      D ]b  }d|j                  |      vsJ t        |j                  |            t        j                  t        |j                  |            d      k(  rbJ  y # 1 sw Y   xY w)Nr   rO   s$   ^%%BoundingBox: (.+) (.+) (.+) (.+)$s)   ^%%HiResBoundingBox: (.+) (.+) (.+) (.+)$r         .)r'   r(   r)   r+   r3   r9   r;   search	MULTILINErangegroupintr5   approxfloat)r?   r@   bufbbhibbis         rH   	test_bboxrv      s    llnGC	 C&lln 
:C	NBI299A3\\#DK41a[ J288A;&&&288A;6==tzz!}1Eq#IIIIJ s   $DD%c                     dt         j                  d<   t        j                  d       t	        j
                  t              5  t        j                  t        j                         d       ddd       y# 1 sw Y   yxY w)z"Test failing latex subprocess callTr   z$22_2_2$r   rO   N)
r$   r%   r'   rW   r5   raisesr2   r3   r)   r+    r"   rH   test_failing_latexrz      sS     #'CLLJJz	|	$ /BJJL./ / /s   *A55A>c                     | j                  d       t        j                  dddd       t        j                  dddd       t        j                  t	        j
                         d	       | j                  \  }d
|j                         v sJ y )NWARNINGg?ra   T)usetex皙?barr   rO   zas if usetex=False)	set_levelr'   figtextr3   r)   r+   records
getMessage)caplogrecords     rH   test_partial_usetexr      sj    
YKKBd+KKBd+KK

T*nnGF6#4#4#6666r"   c                     t         j                  j                  ddd       t        j                  ddd       t        j
                  t        j                         d       y )NTz$\usepackage{color,graphicx,textcomp})r   ztext.latex.preambler`   ra   r   rO   )r$   r%   r&   r'   r   r3   r)   r+   )r   s    rH   test_usetex_preambler      sE    LLF 
 KKBKK

T*r"   z
useafm.epsc                      dt         j                  d<   t        j                         \  } }|j	                          |j                  d       |j                  ddd       y )NTr   r`   qk)r$   r%   r'   r(   rb   axhlinerc   rd   s     rH   test_useafmr      sD     $CLLllnGCOOJJrNGGBDr"   z	type3.epsc                  2    t        j                  ddd       y )Nr`   zI/J)r'   r   ry   r"   rH   test_type3_fontr      s    KKBr"   zcoloredhatcheszerolw.epsc                     t        j                         } | j                  t        ddddddd             | j                  t        dd	d	d
ddd             | j                  t        ddddddd             | j	                          y )N)r   r   r   /noner\   r   )hatch	facecolor	edgecolorrM   )r`   r`   r`   +gr~   )r   r   g333333?g?\b)r'   gca	add_patchr
   rb   )r@   s    rH   !test_colored_hatch_zero_linewidthr      s}    	BLLASF#&!5 6LLS#SF#&#7 8LLc#&!5 6OOr"   )
extensionsc                     | j                         }|j                  ddd| j                  d       |j                          y )Nr   helloT)	transformclip_on)add_subplotrc   transFigure)fig_testfig_refr@   s      rH   test_text_clipr      s8    				BGGAq'X%9%94GHr"   c                     t        j                         }|j                  ddd       | dz  }|j                  |       t        j
                  j                  j                  |d       y )Nr`   defztest.epsF)cache)r'   figurerc   r3   r$   testingcompareconvert)tmp_pathr?   outs      rH   test_d_glyphr      sR     **,CHHRU
Z
CKKKK51r"   ztype42_without_prep.epsmpl20)stylec                  ~    dt         j                  d<   dt         j                  d<   t        j                  ddd       y )N*   ps.fonttypestixzmathtext.fontsetr`   zMass $m$)r$   r%   r'   r   ry   r"   rH   test_type42_font_without_prepr      s1     #%CLL'-CLL#$KKS*%r"   fonttype342c                 ^   | t         j                  d<   t        j                         \  }}|j	                  ddd       t        j                         }|j                  |d       dt        |  d	      z   d
z   }t        j                  ||j                         t        j                        sJ y )Nr   g      ?r`   z&Forty-two is the answer to everything!r   rO   s
   /FontType zutf-8)encodings    def)r$   r%   r'   r(   rc   r)   r+   r3   bytesr;   rk   r9   rl   )r   r?   r@   rr   tests        rH   test_fonttyper      s    "*CLLllnGCGGD#?@
**,CKKDK!5H:AAGKD99T3<<>2<<888r"   c                      t        j                         \  } }|j                  ddgd       t        j                         }| j                  |d       |j                         dkD  sJ y)z-Test that dashed lines do not break PS outputr   r   z--)	linestyler   rO   N)r'   r(   r-   r)   r+   r3   tell)r?   r@   rr   s      rH   test_linedashr      sR    llnGCGGQFdG#
**,CKKDK!88:>>r"   c                      t               } | j                  ddd       t        j                         }| j	                  |d       | j	                  |d       y )Nr`   z
foo

r   rO   r   )r	   rc   r)   r+   r3   )r   rr   s     rH   test_empty_liner     sD    XF
KKS+&
**,C
NN3uN%
NN3tN$r"   c                  ,   t               } | j                  ddt        d            }|j                  D ](  }|j	                  g g        |j                  ddg       * | j                  d       t        j                         }| j                  |d	
       |j                  d       |j                         D cg c]'  }|j                  d      r|j                  d      d   ) }}t        t        |      j!                               dk(  sJ y c c}w )NrK   polar)
projection)
subplot_kw)xticksyticksr   r   zhello, worldr   rO   r   r    )r	   r(   dictflatsetr-   suptitler)   r*   r3   seek	readlines
startswith	partitionmaxr   values)r?   axsr@   rr   lnwdss         rH   test_no_duplicate_definitionr   
  s    
(C
,,q!(@,
AChh 
b$
A LL 
++-CKKEK"HHQK "mmC  <<Q "C " ws|""$%***	"s   ;,Dzmulti_font_type3.epsgRQ?)tolc                  b   t        j                  dg      } t        t        j                  |             j                  dk7  rt        j                  d       t        j                  dddgd       t        j                  d	d
       t        j                         }|j                  ddd       y )NWenQuanYi Zen Heifamilywqy-zenhei.ttcFont may be missingfontDejaVu Sans   r   sizer   r   r   333333?ffffff?"   There are 几个汉字 in between!fmFontPropertiesr   findfontnamer5   r6   r'   rcr   rc   fpr?   s     rH   test_multi_font_type3r     s    			#6"7	8BBKKO!!%55)*FF6=*=>RHFF4!
**,CHHT5>?r"   zmulti_font_type42.epsg?c                  b   t        j                  dg      } t        t        j                  |             j                  dk7  rt        j                  d       t        j                  dddgd       t        j                  d	d
       t        j                         }|j                  ddd       y )Nr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s     rH   test_multi_font_type42r   +  s    			#6"7	8BBKKO!!%55)*FF6=*=>RHFF4"
**,CHHT5>?r"   )5collectionsr   pathlibr   r)   r;   rV   r5   
matplotlibr   r   r   r   matplotlib._apir   matplotlib.figurer	   matplotlib.patchesr
   matplotlib.testing._markersr   r   matplotlib.testing.decoratorsr   r   r$   matplotlib.pyplotpyplotr'   markflakyparametrizerI   rQ   rZ   re   rg   rv   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ry   r"   rH   <module>r     s     	 	   = = 8 $ & G O   ![(AB4	5"	5$m45	5$f-.	5=$'(
E2
D;%&
EM4()7  "'6# C &'6T% @  @" ;- / !/ ;- / ! /J$ / / 7 7 + + <.! " ;-  ! -./ 0 ( ) 2 2 ,-W=& >& c4[19 29	%+( )*5	@ 6	@ *+5	@ 6	@r"   