
    g5                         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)y)"    N)Path)subprocess_run_for_testing)pyplotc           
         t        j                  d       t        t        j                        j
                  d   dz  }|j                         st        j                  d       t        t        j                        j                         }| dz  }|j                  |d       t        t        j                  t        |      t        |      gd       |j                  d      }||k7  rad	j                  t!        j"                  |j%                  d	      |j%                  d	      d
ddd            }t        j&                  d|z         y y )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         Y/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/matplotlib/tests/test_pyplot.pytest_pyplot_up_to_dater)      s   
 cll#++A.1GGJ./&002M+%Hw/	Z#h-8 %%g.L$99  ##D)<+=+=d+C*+b	"# 	< ?G	G	
 %    c                 `   t         j                  j                  t         j                  dd      t         j                  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        t        j                  t         j                        5   |d d        d d d        y # 1 sw Y   ?xY w# 1 sw Y   y xY w)Noldnewkwoc                      y N r-   r.   s     r(   funcz1test_copy_docstring_and_deprecators.<locals>.func.   s     	r*   c                      y 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    XXsu=XX7 8 > 	((. / T4 Tt$;	c66	7 	c66	7 !T4 ! ! ! !s   
D
D$D!$D-c                  f   t        j                         \  } }t        j                  d       |j                         rJ t        j                  d       |j                         sJ t        j                          |j                         rJ t        j                          |j                         sJ y )NFT)r   subplotsboxget_frame_on)figaxs     r(   test_pyplot_boxrE   B   sy    llnGCGGEN   GGDM??GGI   GGI??r*   c                  8    t        j                  g dg d       y )N)   r      )r   	stackplotr1   r*   r(   test_stackplot_smokerJ   N   s    MM)Y'r*   c                     t        j                  t              5  t        j                  d       d d d        t        j                  t              5  t        j                  d       d d d        y # 1 sw Y   BxY w# 1 sw Y   y xY w)NrG   )nrows)ncols)r   raises	TypeErrorr   subplotr1   r*   r(   test_nrows_errorrQ   S   sa    	y	! !	y	! !   s   A2A>2A;>Bc                     t        j                          t        j                         sJ t        j                         5  t        j                         rJ 	 d d d        t        j                         sJ t        j                          t        j                         rJ t        j                         5  t        j                         rJ 	 d d d        t        j                         rJ y # 1 sw Y   xY w# 1 sw Y   ,xY wr0   )r   ionr   is_interactiveioffr1   r*   r(   	test_ioffrV   Z   s    GGI	 (%%''''(HHJ!!###	 (%%''''(!!####( (( (   C*3C6*C36C?c                     t        j                          t        j                         rJ t        j                         5  t        j                         sJ 	 d d d        t        j                         rJ t        j                          t        j                         sJ t        j                         5  t        j                         sJ 	 d d d        t        j                         sJ y # 1 sw Y   xY w# 1 sw Y   ,xY wr0   )r   rU   r   rT   rS   r1   r*   r(   test_ionrY   h   s    HHJ!!###	 $!!###$!!###GGI	 $!!###$$ $$ $rW   c                  Z   t        j                          t        j                         5  t        j                         rJ t        j                         5  t        j                         sJ 	 d d d        t        j                         rJ 	 d d d        t        j                         sJ t        j                         5  t        j                         5  t        j                         rJ 	 d d d        d d d        t        j                         sJ t        j                         5  t        j                          d d d        t        j                         sJ t        j                          t        j                         5  t        j                         sJ t        j                         5  t        j                         rJ 	 d d d        t        j                         sJ 	 d d d        t        j                         rJ t        j                         5  t        j                         5  t        j                         sJ 	 d d d        d d d        t        j                         rJ t        j                         5  t        j                          d d d        t        j                         rJ y # 1 sw Y   DxY w# 1 sw Y   2xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   /xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY wr0   )r   rS   rU   r   rT   r1   r*   r(   test_nested_ion_ioffr[   v   sm   GGI 
 (%%'''WWY 	(%%'''	(%%''''	(
  
 ,XXZ 	,))++++	,, 	 
 HHJ 
 $!!###XXZ 	,))++++	,!!###	$
 !!### 
 (WWY 	(%%'''	(( !!###	 	!!####E	( 	(( (	, 	,, ,
 	, 	,$ $	( 	(( (
 s   +J;J.,J;=KK*K$K"?+K<*K/K<L(L	 L:L!.J8	3J;;KK	KK"K,/K9	4K<<L	L	LL!L*c                  |    	 t        j                  d       y # t        $ r} t        |       dk(  sJ Y d } ~ y 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_      sD    B		# B1v B B 	B BBs    	;6;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 y )Ny   z   )r   rP   gcaax1ax2ax3s      r(   test_subplot_reuserh      st    
++c
C#'')
++c
C#'')
++c
C#'')#::r*   c                  N   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                          y )Npolar
projectionrectilinear)r   figureaxesr]   namerD   re   s     r(   test_axes_kwargsrr      s    JJL	B
((*C>>b==IIKJJL	W	%B
((g
&C>>b==IIKJJL	W	%B
((*C>>88}$$$b==IIKr*   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 y )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'
2C
++aA'
2C>>"99b==b==#::>>#((??#((??77m###88}$$$88wr*   c                  
   t        j                  dd      } t        j                  dd      }| |u sJ | j                          t        j                  dd      }| |usJ | t        j                         j                  vsJ y )Nrj   r   )rl   theta_offsetrG   )r   rP   removegcfro   rd   s      r(   test_subplot_kwarg_collisionrz      sk    
++q
9C
++q
9C#::JJL
++q
9Cc>>cgginn$$$r*   c                      t        j                          t        j                         } t        j                         }| J || u sJ t        j                          y r0   )r   rn   rc   r]   rq   s     r(   test_gcar|      s@    JJL	B
'')C>>"99IIKr*   c                  R   t        j                  d      } | t        j                         u sJ | t        j                  d      u sJ | j                          t        j                  dd      }|t        j                         u sJ | t        j                         j
                  vsJ |t        j                  d      u sJ |j                          t        j                  dd      }|t        j                         u sJ ||usJ |t        j                         j
                  vsJ y )No   rj   rk   rm   )r   rP   rc   rx   ry   ro   rd   s      r(   test_subplot_projection_reuser      s    
++c
C#'')#++c""""JJL
++cg
.C#'')cgginn$$$#++c""""JJL ++cm
4C#'')c>>cgginn$$$r*   c                  8   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        y # 1 sw Y   y xY w)
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>
@ <kk#Td;< < <s   .BBc                  l   t               } t        j                         }| j                  |       d}|D ]b  }|j	                          t        j                  |      }|t        j                         u sJ |j
                  |k(  sJ | j                  |       d t        |       dt        |      z   k(  sJ y )N)aitoffhammerlambert	mollweiderj   rm   r   rk   rG   )setr   rP   addrx   rp   len)created_axesrD   projectionsprojs       r(   test_subplot_change_projectionr     s    5L	BR1K 
		[[D)S[[]"""ww$ |C$4 4444r*   c                  4   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 y )Ng        g      ?rogQ?      ?bo)r   rj   
isinstancer   linesLine2Dro   )ln1ln2s     r(   test_polar_second_callr   .  st    99RT"DCc399++,,,99T2t$DCc399++,,,88sxxr*   c                     t        j                  g d      } t        j                  g d      }t        j                  j	                  |j
                  j                         | j
                  j                                t        j                  g d      } t        j                  g dg d      }t        j                  j	                  |j
                  j                         | j
                  j                                y )N)皙?r   r   r   )position)皙?r   皙?r   )r   ro   nptestingassert_allclosebbox
get_points)axrefaxtests     r(   test_fallback_positionr   8  s    HH)*EXX34FJJv{{557$zz4468 HH)*EXX*5IJFJJv{{557$zz4468r*   c                     t        j                         } | j                  d      }t        j                          t        j                         | k7  sJ t        j                  |d         }t        j                         | k(  sJ || k(  sJ y )Nr   rG   )r   rn   
subfiguresry   )fig1subfigscurrents      r(   %test_set_current_figure_via_subfigurer   F  sj    ::<Dooa GJJL779jj$G779d??r*   c                  4   t        j                         } | j                  d      }|d   j                  dd      }|d   j                  dd       t        j                         |k7  sJ t        j
                  |       t        j                         |k(  sJ y )Nr   r   rG   T)squeeze)r   rn   r   r@   rc   sca)rC   r   rD   s      r(   "test_set_current_axes_on_subfigurer   R  sz    
**,CnnQG			Q		-BAJ4(779??GGBK779??r*   c                      t        j                  d      } t        j                  j	                  | j
                  dddj                  d      d       y )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   ^  sN    !!),GKK%% 
 	  & 	r*   c                     t        t              j                  dz  } | j                         st	        j
                  d       d }| j                         j                  d      }t         ||            }t        t        j                               }|j                  |      }|rt        d|      |j                  |      }|rt        d|      y)z6Test that pyplot_summary lists all the plot functions.z#../../../doc/api/pyplot_summary.rstz#Documentation sources not availablec                     g }d}| D ]b  }|s|j                  d      sd}|r|j                  d      r.|d   j                         sd}D|j                  |j                                d |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  su      	 	/D!??#56%)Ntv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4U;<M0023M&&}5GMk 	 $$]3ECCH)MN 	N r*   c                     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                         }|j                  d      } |j                  d      }t        j                  | t        j                  ddg      k(        sJ |D cg c]  }|j                          c}dd	gk(  sJ y c c}w )NrG   
   T)minor)dtypeg      @g      @ab)tickslabelsr   )r   rn   plotr   arangexticksallarrayfloat64yticksrc   
get_yticksget_yticklabelsget_text)tick_postick_labelsrD   ls       r(   test_minor_ticksr     s    JJLHHRYYq"JJT2Hk66+"BJJ!??@@@"JJc3Zc
$?	B}}4}(H$$4$0K66(bhhSz22333"-.QAJJL.3*<<<.s   "E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 y )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| _         y )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        j                  sJ y # 1 sw Y   xY w)Nzfigure.hooksz0matplotlib.tests.test_pyplot:figure_hook_example)r   
rc_contextr   rn   r   )test_rcrC   s     r(   test_figure_hookr     sS     	KLG 
	  jjl  s   AAc                     t         j                  j                  dd      } t        j                  t
        d      5  t         j                  j                  dd      }d d d        t        j                  t
        d      5  t         j                  j                  | d       d d d        | u sJ t         j                  j                  d      }| |u sJ y # 1 sw Y   zxY w# 1 sw Y   AxY w)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     s    
**

Av

.C	k)T	U 4zz  F 34	k)T	U /

#v./$;;::QD$;;4 4/ /s   "C"C$C!$C-c                      t        j                         } t        j                  t        d      5  t        j                  d      }d d d        y # 1 sw Y   y xY w)Nzcloses all existing figuresr   r   )r   rn   r   r;   r   )r   r   s     r(   test_close_all_warningr     sA    ::<D 
k)F	G !zz% ! ! !s   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     s      
    9 $
>!*	(
$ )$XB20%%2	<5  8		5Np='!!r*   