
    G8c,                         d dl Z d dlZ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&y)    N)Path)pyplot)MatplotlibDeprecationWarningc           
         t        t        j                        j                  d   dz  }|j	                         st        j                  d       t        t        j                        j                         }| j                  d      }|j                  |d       t        j                  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   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)r   mpl__file__parentsexistspytestskipplt	read_textjoin
write_text
subprocessrunsys
executablestrdifflibunified_diffsplitfail)tmpdir
gen_scriptorig_contentsplt_filenew_contentsdiff_msgs         >/usr/lib/python3/dist-packages/matplotlib/tests/test_pyplot.pytest_pyplot_up_to_dater)      s   cll#++A.1GGJ./&002M{{;'Hw/NNCNNC
OS]C%%g.L$99  ##D)<+=+=d+C*+b	"# 	< ?G	G	
 %    c                     t         j                  j                  ddd      t         j                  j                  dd      dd              }t	        j
                  |      dd       } |d         |d         |d d         |d d 	       | rJ t        j                  t              5   |d 
       d d d        t        j                  t              5   |d d        d d d        y # 1 sw Y   5xY w# 1 sw Y   y xY w)Nz	(version)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_func2   s    r*   )r-   )r.   r2   )r,   r0   )	r   _apirename_parametermake_keyword_onlyr   _copy_docstring_and_deprecatorsr   warnsr   )recwarnr3   r5   s      r(   #test_copy_docstring_and_deprecatorsr<   ,   s    XX{E59XXU3 4 : 	((. / T4 Tt$;	2	3 	2	3 !T4 ! ! ! !s   *
C(
C4(C14C=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_boxrC   A   sy    llnGCGGEN   GGDM??GGI   GGI??r*   c                  8    t        j                  g dg d       y )N)   r      )r   	stackplotr1   r*   r(   test_stackplot_smokerH   M   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)NrE   )nrows)ncols)r   raises	TypeErrorr   subplotr1   r*   r(   test_nrows_errorrO   R   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_ioffrT   Y   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   rS   r   rR   rQ   r1   r*   r(   test_ionrW   g   s    HHJ!!###	 $!!###$!!###GGI	 $!!###$$ $$ $rU   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   rQ   rS   r   rR   r1   r*   r(   test_nested_ion_ioffrY   u   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   closerM   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   rN   gcaax1ax2ax3s      r(   test_subplot_reuserf      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rB   rc   s     r(   test_axes_kwargsrp      s    JJL	B
((*C>>b==IIKJJL	W	%B
((g
&C>>b==IIKJJL	W	%B
((*C>>88}$$$b==IIKr*   c                  t   t        j                         } t        j                  ddd      }t        j                  ddd      }t        j                  ddd      }t        j                  t
              5  t        j                  ddd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 # 1 sw Y   xY w)NrE   r   rh   ri   rk   )r   rl   rN   r   r:   r   rm   rn   )rA   rB   rc   rd   re   ax4s         r(   test_subplot_replace_projectionrs      s1    **,C	Q1	B
++aA
C
++aA
C	2	3 7kk!Qg67
++aA'
2C>>"99b==b==#::SXX#((??#((??77m###88}$$$88w7 7s   3D..D7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 )Nrh   r   )rj   theta_offsetrE   )r   rN   removegcfrm   rb   s      r(   test_subplot_kwarg_collisionrx      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   rl   ra   r[   ro   s     r(   test_gcarz      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   rh   ri   rk   )r   rN   ra   rv   rw   rm   rb   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|   rh   ri   T)rh   )rh   rj   zpolar=True, yet projection='3d')match3d)r   rN   r   rL   
ValueErrorrb   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	mollweiderh   rk   r   ri   rE   )setr   rN   addrv   rn   len)created_axesrB   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   rh   
isinstancer   linesLine2Drm   )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   rm   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   rE   )r   rl   
subfiguresrw   )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   rE   T)squeeze)r   rl   r   r>   ra   sca)rA   r   rB   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   importorskipr   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       | j                         }t        j                  d|t        j                        }t        d |j                  d      j                  d      D              }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 availablez:nosignatures:\n\n(.*?)\n\nc              3   <   K   | ]  }|j                           y wr0   )strip).0lines     r(   	<genexpr>z*test_doc_pyplot_summary.<locals>.<genexpr>t  s     H

Hs   rE   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   researchDOTALLr   groupr    r   get_plot_commands
differenceAssertionError)pyplot_docsr   mdoc_functionsplot_commandsmissingextras          r(   test_doc_pyplot_summaryr   l  s    x.''*OOK9:!!#E
		0%CAH1A1A$1GHHM--/0M&&}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 )NrE   
   T)minor)dtypeg      @g      @ab)tickslabelsr   )r   rl   plotr   arangexticksallarrayfloat64yticksra   
get_yticksget_yticklabelsget_text)tick_postick_labelsrB   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)'r   r   numpyr   r   r   pathlibr   r   
matplotlibr   r   r   matplotlib._apir   r)   r<   rC   rH   rO   rT   rW   rY   r]   rf   rp   rs   rx   rz   r}   r   r   r   r   r   r   r   r   r   r1   r*   r(   <module>r      s     	   
    $ 8
8!*	(
$ )$XB22%%2	<5  8		N0=r*   