
    (?e3                         d dl Z d dlZd dlZd dlmZ d dlZd dlZd dl	m
Z
 d dlmZ d Zd Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d Z'dS )     N)Path)subprocess_run_for_testing)pyplotc           
         t          j        d           t          t          j                  j        d         dz  }|                                st          j        d           t          t          j                  	                                }| 
                    d          }|                    |d           t          t          j        t          |          t          |          gd           |	                    d          }||k    rld	
                    t!          j        |                    d	          |                    d	          d
ddd                    }t          j        d|z             d S d S )Nblack   ztools/boilerplate.pyzboilerplate.py not foundz	pyplot.pyzutf-8T)check
zfound pyplot.pyzexpected pyplot.pyr    )fromfiletofilenlinetermzpyplot.py is not up-to-date. Please run 'python tools/boilerplate.py' to update pyplot.py. This needs to be done from an environment where your current working copy is installed (e.g. 'pip install -e'd). Here is a diff of unexpected differences:
%s)pytestimportorskipr   mpl__file__parentsexistsskipplt	read_textjoin
write_textr   sys
executablestrdifflibunified_diffsplitfail)tmpdir
gen_scriptorig_contentsplt_filenew_contentsdiff_msgs         <lib/python3.11/site-packages/matplotlib/tests/test_pyplot.pytest_pyplot_up_to_dater)      sv   
   cl##+A.1GGJ 0.///&&0022M{{;''Hw///	Z#h--8    %%g..L$$99 ##D))<+=+=d+C+C*+b	" " "# # 	< ?G	G	
 	
 	
 	
 	
 %$    c                 X   t           j                            ddd          t           j                            dd          dd                        }t	          j        |          dd            } |d             |d             |d d             |d d 	           | rJ t          j        t           j                  5   |d 
           d d d            n# 1 swxY w Y   t          j        t           j                  5   |d d            d d d            d S # 1 swxY w Y   d S )Nz	(version)oldnewkwoc                     d S N r-   r.   s     r(   funcz1test_copy_docstring_and_deprecators.<locals>.func.   s	     	r*   c                     d S r0   r1   r2   s     r(   wrapper_funcz9test_copy_docstring_and_deprecators.<locals>.wrapper_func3   s    r*   )r-   )r.   r2   )r,   r0   )	r   _apirename_parametermake_keyword_onlyr   _copy_docstring_and_deprecatorsr   warnsMatplotlibDeprecationWarning)recwarnr3   r5   s      r(   #test_copy_docstring_and_deprecatorsr=   -   s   X{E599XU33   43 :9 	(..   /. LLTL4    LTt$$$$	c6	7	7                	c6	7	7 ! !T4   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !s$   CC #C DD#&D#c                  ~   t          j                    \  } }t          j        d           |                                rJ t          j        d           |                                sJ t          j                     |                                rJ t          j                     |                                sJ d S )NFT)r   subplotsboxget_frame_on)figaxs     r(   test_pyplot_boxrD   B   s    lnnGCGENNN     GDMMM??GIII     GIII??r*   c                  8    t          j        g dg d           d S )N)   r      )r   	stackplotr1   r*   r(   test_stackplot_smokerI   N   s"    M)))YYY'''''r*   c                      t          j        t                    5  t          j        d           d d d            n# 1 swxY w Y   t          j        t                    5  t          j        d           d d d            d S # 1 swxY w Y   d S )NrF   )nrows)ncols)r   raises	TypeErrorr   subplotr1   r*   r(   test_nrows_errorrP   S   s   	y	!	!  !              	y	!	!  !                 s!   <A A  BB
Bc                     t          j                     t          j                    sJ t          j                    5  t          j                    rJ 	 d d d            n# 1 swxY w Y   t          j                    sJ t          j                     t          j                    rJ t          j                    5  t          j                    rJ 	 d d d            n# 1 swxY w Y   t          j                    rJ d S r0   )r   ionr   is_interactiveioffr1   r*   r(   	test_ioffrU   Z   sd   GIII	 ( (%''''''( ( ( ( ( ( ( ( ( ( ( ( ( ( (HJJJ!#####	 ( (%''''''( ( ( ( ( ( ( ( ( ( ( ( ( ( (!########   AA#&A#:CC!$C!c                     t          j                     t          j                    rJ t          j                    5  t          j                    sJ 	 d d d            n# 1 swxY w Y   t          j                    rJ t          j                     t          j                    sJ t          j                    5  t          j                    sJ 	 d d d            n# 1 swxY w Y   t          j                    sJ d S r0   )r   rT   r   rS   rR   r1   r*   r(   test_ionrX   h   sd   HJJJ!#####	 $ $!######$ $ $ $ $ $ $ $ $ $ $ $ $ $ $!#####GIII	 $ $!######$ $ $ $ $ $ $ $ $ $ $ $ $ $ $rV   c                  R   t          j                     t          j                    5  t          j                    rJ t          j                    5  t          j                    sJ 	 d d d            n# 1 swxY w Y   t          j                    rJ 	 d d d            n# 1 swxY w Y   t          j                    sJ t          j                    5  t          j                    5  t          j                    r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                    sJ t          j                    5  t          j                     d d d            n# 1 swxY w Y   t          j                    sJ t          j                     t          j                    5  t          j                    sJ t          j                    5  t          j                    rJ 	 d d d            n# 1 swxY w Y   t          j                    sJ 	 d d d            n# 1 swxY w Y   t          j                    rJ t          j                    5  t          j                    5  t          j                    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                    rJ t          j                    5  t          j                     d d d            n# 1 swxY w Y   t          j                    rJ d S r0   )r   rR   rT   r   rS   r1   r*   r(   test_nested_ion_ioffrZ   v   sH   GIII 
 ( (%'''''WYY 	( 	(%''''''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(%''''''	( ( ( ( ( ( ( ( ( ( ( ( ( ( (
  
 , ,XZZ 	, 	,)++++++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,, , , , , , , , , , , , , , , 	  


               HJJJ 
 $ $!#####XZZ 	, 	,)++++++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,!######	$ $ $ $ $ $ $ $ $ $ $ $ $ $ $
 !##### 
 ( (WYY 	( 	(%''''''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(( ( ( ( ( ( ( ( ( ( ( ( ( ( ( !#####	  			              !#######s   )B A3'B 3A7	7B :A7	;B  B$'B$D!'D
>D!
D	D!D	D!!D%(D%E44E8;E8:)H3#H:H3H
	
H3H
	H33H7:H7&J4:JJ4J!	!J4$J!	%J44J8;J8'LLLc                      	 t          j        d           d S # t          $ r } t          |           dk    sJ Y d } ~ d S d } ~ ww xY w)Ng?zQclose() argument must be a Figure, an int, a string, or None, not <class 'float'>)r   closerN   r   )es    r(   
test_closer^      s    B	# B B B1vv B B B B B B B B B B BBs    
A=Ac                     t          j        d          } | t          j                    u sJ t          j        d          }|t          j                    u sJ t          j        d          }| t          j                    u sJ | |u sJ d S )Ny   z   )r   rO   gcaax1ax2ax3s      r(   test_subplot_reuserg      s    
+c

C#'))
+c

C#'))
+c

C#'))#::::::r*   c                  0   t          j                     t          j                    } t          j                    }| J || usJ t          j                     t          j                     t          j        d          } t          j        d          }| J || usJ t          j                     t          j                     t          j        d          } t          j                    }| J |j        dk    sJ || usJ t          j                     d S )Npolar
projectionrectilinear)r   figureaxesr\   namerC   rd   s     r(   test_axes_kwargsrq      s    JLLL	B
(**C>>>b====IKKKJLLL	W	%	%	%B
(g
&
&
&C>>>b====IKKKJLLL	W	%	%	%B
(**C>>>8}$$$$b====IKKKKKr*   c                     t          j                    } t          j        ddd          }t          j        ddd          }t          j        ddd          }t          j        dddd          }t          j        dddd          }|J ||u sJ ||usJ ||usJ ||u sJ || j        v sJ || j        v sJ || j        v sJ |j        dk    sJ |j        dk    sJ |j        dk    sJ d S )NrF   r   ri   rj   rl   )r   rm   rO   rn   ro   )rB   rC   rd   re   rf   ax4s         r(   test_subplot_replace_projectionrt      s!    *,,C	Q1		B
+aA

C
+aA

C
+aA'
2
2
2C
+aA'
2
2
2C>>>"9999b====b====#::::>>>>#(????#(????7m####8}$$$$8wr*   c                     t          j        dd          } t          j        dd          }| |u sJ |                                  t          j        dd          }| |usJ | t          j                    j        vsJ d S )Nri   r   )rk   theta_offsetrF   )r   rO   removegcfrn   rc   s      r(   test_subplot_kwarg_collisionry      s    
+q
9
9
9C
+q
9
9
9C#::::JJLLL
+q
9
9
9Cc>>>>cgiin$$$$$$r*   c                      t          j                     t          j                    } t          j                    }| J || u sJ t          j                     d S r0   )r   rm   rb   r\   rp   s     r(   test_gcar{      sH    JLLL	B
'))C>>>"9999IKKKKKr*   c                  <   t          j        d          } | t          j                    u sJ | t          j        d          u sJ |                                  t          j        dd          }|t          j                    u sJ | t          j                    j        vsJ |t          j        d          u sJ |                                 t          j        dd          }|t          j                    u sJ ||usJ |t          j                    j        vsJ d S )No   ri   rj   rl   )r   rO   rb   rw   rx   rn   rc   s      r(   test_subplot_projection_reuser~      s   
+c

C#'))#+c""""""JJLLL
+cg
.
.
.C#'))cgiin$$$$#+c""""""JJLLL +cm
4
4
4C#'))c>>>>cgiin$$$$$$r*   c                  :   t          j        dd          } t          j        dd          }t          j        ddd          }| |u sJ | |u sJ t          j        t          d          5  t          j        ddd	          }d d d            d S # 1 swxY w Y   d S )
Nr}   ri   rj   T)ri   )ri   rk   zpolar=True, yet projection='3d')match3d)r   rO   r   rM   
ValueErrorrc   s      r(    test_subplot_polar_normalizationr     s    
+cg
.
.
.C
+c
&
&
&C
+c'
:
:
:C#::::#::::	z>
@ 
@ 
@ < <k#Td;;;< < < < < < < < < < < < < < < < < <s   +BBBc                     t                      } t          j                    }|                     |           d}|D ]d}|                                 t          j        |          }|t          j                    u sJ |j        |k    sJ |                     |           et          |           dt          |          z   k    sJ d S )N)aitoffhammerlambert	mollweideri   rl   r   rj   rF   )setr   rO   addrw   ro   len)created_axesrC   projectionsprojs       r(   test_subplot_change_projectionr     s    55L	BR1K  
		[D)))S[]]""""w$|C$4$4 4444444r*   c                  
   t          j        ddd          \  } t          | t          j        j                  sJ t          j        ddd          \  }t          |t          j        j                  sJ | j        |j        u sJ d S )Ng        g      ?rogQ?      ?bo)r   ri   
isinstancer   linesLine2Drn   )ln1ln2s     r(   test_polar_second_callr   .  s}    9RT""DCc39+,,,,,9T2t$$DCc39+,,,,,8sxr*   c                     t          j        g d          } t          j        g d          }t          j                            |j                                        | j                                                   t          j        g d          } t          j        g dg d          }t          j                            |j                                        | j                                                   d S )N)皙?r   r   r   )position)皙?r   皙?r   )r   rn   nptestingassert_allclosebbox
get_points)axrefaxtests     r(   test_fallback_positionr   8  s    H)))**EX333444FJv{5577$z44668 8 8 H)))**EX***5I5I5IJJJFJv{5577$z44668 8 8 8 8r*   c                  $   t          j                    } |                     d          }t          j                     t          j                    | k    sJ t          j        |d                   }t          j                    | k    sJ || k    sJ d S )Nr   rF   )r   rm   
subfiguresrx   )fig1subfigscurrents      r(   %test_set_current_figure_via_subfigurer   F  s{    :<<Dooa  GJLLL799j$$G799d??????r*   c                  V   t          j                    } |                     d          }|d                             dd          }|d                             dd           t          j                    |k    sJ t          j        |           t          j                    |k    sJ d S )Nr   r   rF   T)squeeze)r   rm   r   r?   rb   sca)rB   r   rC   s      r(   "test_set_current_axes_on_subfigurer   R  s    
*,,CnnQG			Q		-	-BAJ4(((799????GBKKK799??????r*   c                      t          j        d          } t          j                            | j        ddd                    d          d           d S )NIPythonz--pylabz-c;)zimport matplotlib.pyplot as pltz<assert plt._REPL_DISPLAYHOOK == plt._ReplDisplayHook.IPYTHON<   )timeout)r   r   r   r   subprocess_run_helperstart_ipythonr   )r   s    r(   test_pylab_integrationr   ^  sb    !),,GK%% 
 	 	  & 	 	 	 	 	r*   c                     t          t                    j        dz  } |                                 st	          j        d           d }|                                                     d          }t           ||                    }t          t          j
                              }|                    |          }|rt          d|          |                    |          }|rt          d|          dS )z6Test that pyplot_summary lists all the plot functions.z#../../../doc/api/pyplot_summary.rstz#Documentation sources not availablec                    g }d}| D ]x}|s|                     d          rd}|r|                     d          r4|d                                         sd}Q|                    |                                           y|S )ae  
        Return a list of all the functions that are mentioned in the
        autosummary blocks contained in *lines*.

        An autosummary block looks like this::

            .. autosummary::
               :toctree: _as_gen
               :template: autosummary.rst
               :nosignatures:

               plot
               plot_date

        Fz.. autosummary::Tz   :r   )
startswithisspaceappendstrip)r   	functionsin_autosummarylines       r(   extract_documented_functionsz=test_doc_pyplot_summary.<locals>.extract_documented_functionsr  s      	 	/ 	/D! /??#566 *%)N tv66 Aw(( %*N  ....r*   r
   zsThe following pyplot functions are not listed in the documentation. Please add them to doc/api/pyplot_summary.rst: zThe following functions are listed in the pyplot documentation, but they do not exist in pyplot. Please remove them from doc/api/pyplot_summary.rst: N)r   r   parentr   r   r   r   r    r   r   _get_pyplot_commands
differenceAssertionError)pyplot_docsr   r   doc_functionsplot_commandsmissingextras          r(   test_doc_pyplot_summaryr   l  s.   x..'*OOK ;9:::  B !!##))$//E44U;;<<M02233M&&}55G    	 $$]33E NMCHM MN N 	NN Nr*   c                  b   t          j                     t          j        t          j        dd                     t          j        d          \  } }t          j        |t          j        g t          j                  k              sJ |g k    sJ t          j	        ddgdd	gd
           t          j
                    }|                    d          } |                    d          }t          j        | t          j        ddg          k              sJ d |D             dd	gk    sJ d S )NrF   
   T)minor)dtypeg      @g      @ab)tickslabelsr   c                 6    g | ]}|                                 S r1   )get_text).0ls     r(   
<listcomp>z$test_minor_ticks.<locals>.<listcomp>  s     ...QAJJLL...r*   )r   rm   plotr   arangexticksallarrayfloat64yticksrb   
get_yticksget_yticklabels)tick_postick_labelsrC   s      r(   test_minor_ticksr     s"   JLLLHRYq"JT222Hk6+"BJ!?!?!??@@@@@"Jc3Zc
$????	B}}4}((H$$4$00K6(bhSz22233333..+...3*<<<<<<r*   c                     t          j        d           t          j                    } t          j                    } t          t          j                              dk    sJ t          j        d           t          t          j                              dk    sJ t          j        t          j                  5  t          j        d           d d d            n# 1 swxY w Y   t          t          j                              dk    sJ d S )Naggr   svgr   )	r   switch_backendrm   r   get_fignumsr   r:   r   r;   )rB   s    r(   test_switch_backend_no_closer     s   u
*,,C
*,,Cs  !!Q&&&&us  !!Q&&&&	c6	7	7 " "5!!!" " " " " " " " " " " " " " "s  !!Q&&&&&&s   9CC!Cc                     d| _         d S )NT)_test_was_here)rm   s    r(   figure_hook_exampler     s     Fr*   c                      ddgi} t          j        |           5  t          j                    }d d d            n# 1 swxY w Y   |j        sJ d S )Nzfigure.hooksz0matplotlib.tests.test_pyplot:figure_hook_example)r   
rc_contextr   rm   r   )test_rcrB   s     r(   test_figure_hookr     s     	KLG 
	 	   jll               s   :>>)(r   numpyr   r   pathlibr   r   
matplotlibr   matplotlib.testingr   r   r   r)   r=   rD   rI   rP   rU   rX   rZ   r^   rg   rq   rt   ry   r{   r~   r   r   r   r   r   r   r   r   r   r   r   r   r1   r*   r(   <module>r      s        



            9 9 9 9 9 9 $ $ $ $ $ $
 
 
>! ! !*	 	 	( ( (
  $ $ $     )$ )$ )$XB B B    2  0% % %  % % %2	< 	< 	<5 5 5      8 8 8	 	 		 	 	  5N 5N 5Np= = =	' 	' 	'! ! !    r*   