
    P/Phm                     @   d dl mZ 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 d dlmZmZ dZdZeeiZed d	            Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z e	j!        "                    dddgddg          d             Z#d Z$d Z%d Z&d Z'dS )!    )contextmanager)Path)TemporaryDirectoryN)pyplotstyle)USER_LIBRARY_PATHSSTYLE_EXTENSIONz
image.cmappinkc              #     K   |st           }|  dt           }	 t                      5 }t          ||                              d                    d |                                D                       d           t          j        |           t          j
                     dV  ddd           n# 1 swxY w Y   t          j
                     dS # t          j
                     w xY w)zAContext manager to create a style sheet in a temporary directory..
c              3   *   K   | ]\  }}| d | V  dS )z: N ).0kvs      [/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/matplotlib/tests/test_style.py	<genexpr>ztemp_style.<locals>.<genexpr>   s0      CC$!QQ++!++CCCCCC    utf-8encodingN)DUMMY_SETTINGSr	   r   r   
write_textjoinitemsr   appendr   reload_library)
style_namesettings	temp_filetmpdirs       r   
temp_styler#      s4       "!1111I!! 	V##..		CC(..2B2BCCCCC  / " " " %f--- """EEE	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s/   C B B3'C 3B77C :B7;C C(c                     ddi}d}t          ||          5  	 d d d            n# 1 swxY w Y   t          | j                  dk    r!|| j        d                                         v sJ d S )Nfoobarbasename   r   )r#   lenrecords
getMessage)caplogSETTINGSr'   s      r   )test_invalid_rc_warning_includes_filenamer.   '   s    u~HH	Hh	'	'                 1$$FN1-88::::::::s   %))c                      t          dt                    5  dt          j        v sJ 	 d d d            d S # 1 swxY w Y   d S )N_test_)r#   r   r   	availabler   r   r   test_availabler2   1   s    	Hn	-	- + +5?*****+ + + + + + + + + + + + + + + + + +s   599c                  (   dt           j        t          <   t          dt                    5  t          j        d          5  t           j        t                   t          k    sJ 	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S NgraytestmplrcParamsPARAMr#   r   r   contextVALUEr   r   r   test_user=   6   s    CL	FN	+	+ 0 0]6"" 	0 	0<&%/////	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0s4   B#A/#B/A3	3B6A3	7BBBc                    | dz  }|                     dd           t          dt                    5  dt          j        dk    rdnd	z   |                                                                z   }t          j        |          5  t          j
        d
         dk    sJ 	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nfilezaxes.facecolor: adeader   r   r6   zfile:win32z/// zaxes.facecolorz#adeade)r   r#   r   sysplatformresolveas_posixr   r;   r8   r9   )tmp_pathpathurls      r   test_use_urlrI   =   sS   fDOO,wO???	FN	+	+ ? ?<722%%<((**+ ]3 	? 	?< 01Y>>>>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?	? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?s6   ACB+C+B/	/C2B/	3CC
Cc                 l   dt           j        t          <   | dt           z  }|                    t           dt
           d           t          j        |          5  t           j        t                   t
          k    sJ 	 d d d            n# 1 swxY w Y   t           j        t                   dk    sJ d S )Nr5   ztext.z : r   r   )r8   r9   r:   r	   r   r<   r   r;   )rF   rG   s     r   test_single_pathrK   H   s     CL/o///DOOu((((7O;;;	t		 , ,|E"e+++++, , , , , , , , , , , , , , ,<&((((((s   #BBBc                  `   dt           j        t          <   t          dt                    5  t          j        d          5  t           j        t                   t          k    sJ 	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t           j        t                   dk    sJ d S r4   r7   r   r   r   test_contextrM   Q   s    CL	FN	+	+ 0 0]6"" 	0 	0<&%/////	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 <&((((((s4   B#A/#B/A3	3B6A3	7BB
B
c                     d} d}| t           j        t          <   t          j        t          |i          5  t           j        t                   |k    sJ 	 d d d            n# 1 swxY w Y   t           j        t                   | k    sJ d S )Nr5   blue)r8   r9   r:   r   r;   original_valueother_values     r   test_context_with_dictrS   Z   s    NK(CL	{+	,	, 2 2|E"k111112 2 2 2 2 2 2 2 2 2 2 2 2 2 2<.000000s   AA#&A#c                  p   d} d}| t           j        t          <   t          dt                    5  t          j        dt          |ig          5  t           j        t                   |k    sJ 	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t           j        t                   | k    sJ d S Nr5   rO   r6   )r8   r9   r:   r#   r   r   r;   rP   s     r   'test_context_with_dict_after_namedstylerV   c   s'   NK(CL	FN	+	+ 6 6]FUK$89:: 	6 	6<&+55555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	66 6 6 6 6 6 6 6 6 6 6 6 6 6 6 <.000000s5   BA7+B7A;	;B>A;	?BBBc                  z   d} d}| t           j        t          <   t          dt                    5  t          j        t          |idg          5  t           j        t                   t          k    sJ 	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t           j        t                   | k    sJ d S rU   r7   rP   s     r   (test_context_with_dict_before_namedstylerX   n   s'   NK(CL	FN	+	+ 0 0]UK0&9:: 	0 	0<&%/////	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 <.000000s5   B#A<0B<B 	 BB 	BBBc                     d} d}d}||i}| t           j        t          <   | t           j        |<   t          dt                    5  t          j        d|g          5  t           j        t                   t          k    sJ t           j        |         |k    sJ 	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t           j        t                   | k    sJ t           j        |         | k    sJ d S )Nr5   ztext.usetexTr6   r7   )rQ   other_paramrR   ds       r   .test_context_with_union_of_dict_and_namedstyler\   y   sp   NKK	k"A(CL%0CL	FN	+	+ < <]FA;'' 	< 	<<&%////<,;;;;;	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<< < < < < < < < < < < < < < < <.0000<$[999999s6   B:;B#B:#B'	'B:*B'	+B::B>B>c                     d} d}t          j        t          |i          5  t          j        t                   |k    sJ t          j        t          | dd i          }t          j        t                    5  |5  	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          j        t                   |k    sJ 	 d d d            d S # 1 swxY w Y   d S )Nr5   rO   badparam)r   r;   r:   r8   r9   pytestraisesKeyError)rQ   rR   xs      r   test_context_with_badparamrc      s   NK	{+	,	, 2 2|E"k1111M5.*dCDD]8$$ 	 	                	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 |E"k111112 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2sZ   AC4B7B9BB		BB	BCB 	 C#B 	$ CCCequiv_styles)mpl20default)mpl15classicre   rg   )idsc                 :   g }| D ]_}t          j        |          5  |                    t          j                                                   d d d            n# 1 swxY w Y   `|d         }t          | dd          |dd                    D ]\  }}||k    sJ d S )Nr   r(   )r   r;   r   r8   r9   copyzip)rd   rc_dictsstyrc_basenmrcs         r   
test_aliasrr      s    
 H 1 1]3 	1 	1OOCL--//000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 qkGl122&55  B"}}}}} s   2AA	 A	c                      t           j        d         J t          j                     t           j        d         dk    sJ t          j                                         t           j        d         dk    sJ d S Nzpath.sketch)r(   d      )r8   r9   pltxkcdnptestingbreak_cyclesr   r   r   test_xkcd_no_cmr|      sj    <&...HJJJ<&+5555J<&+555555r   c                      t           j        d         J t          j                    5  t           j        d         dk    sJ 	 d d d            n# 1 swxY w Y   t           j        d         J d S rt   )r8   r9   rw   rx   r   r   r   test_xkcd_cmr~      s    <&...	 : :|M*k99999: : : : : : : : : : : : : : :<&.....s   AAAc                  `    t           j        j        j        h t           j        j        k    sJ d S N)r8   r   coreSTYLE_BLACKLISTrcsetup_validatorsr   r   r   test_up_to_date_blacklistr      s+    9>)-Gs{/F-GGGGGGGr   c                 ^   |                     |            |                    |            | dz  }|                                 |dz                      dd           |                    d                              dd           t
          j                            d           t
          j        d	         d
k    sJ t
          j                            d           t
          j        d	         dk    sJ t
          j                            d           t
          j        d	         dk    sJ d S )Nmpl_test_style_pkgztest_style.mplstylezlines.linewidth: 42r   r   z	.mplstylezlines.linewidth: 84zmpl_test_style_pkg.test_stylezlines.linewidth*   zmpl_test_style_pkg.mplstyleT   z./mpl_test_style_pkg.mplstyle)	syspath_prependchdirmkdirr   with_suffixr8   r   user9   )rF   monkeypatchpkg_paths      r   test_style_from_moduler      s-   )))h..HNN%%11 2 1 1 1%%00 1 1 1 1IMM1222<)*b0000IMM/000<)*b0000IMM1222<)*b000000r   r   )(
contextlibr   pathlibr   tempfiler   rB   numpyry   r_   
matplotlibr8   r   rw   r   matplotlib.style.corer   r	   r:   r<   r   r#   r.   r2   r=   rI   rK   rM   rS   rV   rX   r\   rc   markparametrizerr   r|   r~   r   r   r   r   r   <module>r      s   % % % % % %       ' ' ' ' ' ' 



          + + + + + + + + E E E E E E E E 	    &< < <+ + +
0 0 0? ? ?) ) )) ) )1 1 11 1 11 1 1: : : 	2 	2 	2 ..0%w/  1 1 	1 16 6 6/ / /H H H1 1 1 1 1r   