
    P/Ph5                         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  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z  }|
                    |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
write_textr   sys
executablestrjoindifflibunified_diffsplitfail)tmp_path
gen_scriptorig_contentsplt_filenew_contentsdiff_msgs         \/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/matplotlib/tests/test_pyplot.pytest_pyplot_up_to_dater)      so   
   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                    t           j                            t           j        dd          t           j                            t           j        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 )N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__version__make_keyword_onlyr   _copy_docstring_and_deprecatorsr   warnsMatplotlibDeprecationWarning)recwarnr3   r5   s      r(   #test_copy_docstring_and_deprecatorsr>   -   s   Xsu==X77   87 >= 	(..   /. LLTL4    LTt$$$$	c6	7	7                	c6	7	7 ! !T4   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !s$   C00C47C4D33D7:D7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_boxrE   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_smokerJ   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 )NrG   )nrows)ncols)r   raises	TypeErrorr   subplotr1   r*   r(   test_nrows_errorrQ   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_ioffrV   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   rU   r   rT   rS   r1   r*   r(   test_ionrY   h   sd   HJJJ!#####	 $ $!######$ $ $ $ $ $ $ $ $ $ $ $ $ $ $!#####GIII	 $ $!######$ $ $ $ $ $ $ $ $ $ $ $ $ $ $rW   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   rS   rU   r   rT   r1   r*   r(   test_nested_ion_ioffr[   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   closerO   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   rP   gcaax1ax2ax3s      r(   test_subplot_reuserh      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rD   re   s     r(   test_axes_kwargsrr      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 )NrG   r   rj   rk   rm   )r   rn   rP   ro   rp   )rC   rD   re   rf   rg   ax4s         r(   test_subplot_replace_projectionru      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 )Nrj   r   )rl   theta_offsetrG   )r   rP   removegcfro   rd   s      r(   test_subplot_kwarg_collisionrz      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   rn   rc   r]   rq   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   rj   rk   rm   )r   rP   rc   rx   ry   ro   rd   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~   rj   rk   T)rj   )rj   rl   zpolar=True, yet projection='3d'match3d)r   rP   r   rN   
ValueErrorrd   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	mollweiderj   rm   r   rk   rG   )setr   rP   addrx   rp   len)created_axesrD   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   rj   
isinstancer   linesLine2Dro   )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   ro   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   rG   )r   rn   
subfiguresry   )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   rG   T)squeeze)r   rn   r   r@   rc   sca)rC   r   rD   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 )NrG   
   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   rn   plotr   arangexticksallarrayfloat64yticksrc   
get_yticksget_yticklabels)tick_postick_labelsrD   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        d           t          t          j                              dk    sJ d S )Naggr   svg)r   switch_backendrn   r   get_fignums)rC   s    r(   test_switch_backend_no_closer     s    u
*,,C
*,,Cs  !!Q&&&&us  !!Q&&&&us  !!Q&&&&&&r*   c                     d| _         d S )NT)_test_was_here)rn   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   rn   r   )test_rcrC   s     r(   test_figure_hookr     s     	KLG 
	 	   jll               s   :>>c                     t           j                            dd          } t          j        t
          d          5  t           j                            dd          }d d d            n# 1 swxY w Y   t          j        t
          d          5  t           j                            | d           d d d            n# 1 swxY w Y   | |u sJ t           j                            d          }| |u sJ d S )NrG   )rG   r   )figsizez)Ignoring specified arguments in this callr   )rH      )      )r   r   rn   r   r;   UserWarning)rC   fig2fig3s      r(   test_multiple_same_figure_callsr     sZ   
*

Av

.
.C	k)T	U	U	U 4 4z  F 334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	k)T	U	U	U / /
#v.../ / / / / / / / / / / / / / /$;;;;:QD$;;;;;;s#   "A++A/2A/"B??CCc                      t          j                    } t          j        t          d          5  t          j        d          }d d d            d S # 1 swxY w Y   d S )Nzcloses all existing figuresr   r   )r   rn   r   r;   r   )r   r   s     r(   test_close_all_warningr     s    :<<D 
k)F	G	G	G ! !z%  ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !s   AAA)*r   numpyr   r   pathlibr   r   
matplotlibr   matplotlib.testingr   r   r   r)   r>   rE   rJ   rQ   rV   rY   r[   r_   rh   rr   ru   rz   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r1   r*   r(   <module>r     s3        



            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*   