
    (?e!                        d dl mZ d dlZ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mZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d	 Zd
 Ze	j         !                    d           edg          d                         Z"d Z#e	j         !                    d           edg          d                         Z$d Z%d Z&d Z'd Z(d Z) G d d          Z*d Z+d Z,d Z-d Z.ej/        0                    de
j1        2                                          d             Z3d Z4d Z5d  Z6d! Z7d" Z8d# Z9dS )$    )BytesION)cm)subprocess_run_helper)check_figures_equal)rrulewrapper)VertexSelector)parasite_axesc                  *   t          j                    } t          j        | t	                      t          j                   t          j        d          }t          j        |t	                      t          j                   t          j        d          }t          j        t          j
        d          d           t          j                     t          j        |t	                      t          j                   t          j                     t          j        t          j
        d          t          j
        d                     t          j        t          j                    t	                      t          j                   t          j                    } t          j                    }t          j        t          j
        d                     |                    d           t          j        | t	                      t          j                   d S )	Ny   polar)
projection
   foobarlabel)xheightlog)pltfigurepickledumpr   HIGHEST_PROTOCOLsubplotaxesplotnparangelegendbargca
set_yscalefigaxs     <lib/python3.11/site-packages/matplotlib/tests/test_pickle.pytest_simpler'      s[   
*,,C
KWYY 7888	S		B
KGIIv6777	W	%	%	%BHRYr]](++++JLLL
KGIIv6777
 JLLLGbimmBIbMM2222
K		799f&=>>>
*,,C	BHRYr]]MM%
KWYY 788888    c                 R   |                      d           t          j        |            t          j        d           t	          j        d          t	          j        d          }}t	          j        ddd                              dd          x}x}}t	          j        |dz            }t          j	        ddd	           t          j
        t          t          d                               t          j        d
           t          j	        ddd           t          j        |ddg           t          j                     t          j	        ddd           t          j        |           t          j	        ddd           t          j        |           t          j        d           t          j	        ddd           t          j        |           t          j	        ddd          }|                    dd           |                    dd           t          j        ||||           t          j	        ddd          }|                    dd           |                    dd           t          j        ||||           t          j	        ddd           t          j        ||dz  d           t          j        d           t          j	        ddd           t          j        ||dz  dd           t          j        d           |                                  d S )N)r      z!Can you fit any more in a figure?   r   r   P   g333333      hello   z//ooo)hatches   zhello
world!   r*      	   z$x^2$r   z
upper left)locg      g?g?)xerryerrT)	draggable)set_size_inchesr   r   suptitler   r   linspacereshapesinr   r   listrangeylabelcontourfcolorbar
pcolormeshimshowpcolorset_xlimset_ylim
streamplotquiverscatterr   errorbaralign_ylabels)fig_refr   ydatauvr%   s          r&   _generate_complete_test_figurerT   0   s   G$$$JwL4555 9Q<<2qA;q"b))11"a888D81q
q4xA K1aHT%))__JwK1aLe}----LNNNK1aN4K1aJtJK1aJt	Q1		BKK1KK1N1aA	Q1		BKK1KK1Jq!QK1aK16))))J<    K1aLAH3S1111Jr(   defaultpng)
extensionsc                    t          |           t          j        |t          j                  }dd t	          j        |          D             vsJ t          j        |          }|j                                         | 	                    |
                                           |                     |j        j                                                   t          j        |           d S )NFigureCanvasAggc                     g | ]\  }}}|	S  r[   ).0opargposs       r&   
<listcomp>z!test_complete.<locals>.<listcomp>m   s    $U$U$U\RcS$U$U$Ur(   )rT   r   dumpsr   pickletoolsgenopsloadscanvasdrawr;   get_size_inchesfigimagerendererbuffer_rgbar   close)fig_testrO   pklloadeds       r&   test_completero   c   s     #7+++
,w 7
8
8C
 $U$U[=OPS=T=T$U$U$UUUUU\#F
MV3355666fm,88::;;;Ifr(   c                      dd l } dd l}| j        d         }t          |d          5 } |j        |          }d d d            n# 1 swxY w Y   t          t           |j        |                               d S )Nr   PICKLE_FILE_PATHrb)osr   environopenloadprintstrra   )rs   r   pathblobr$   s        r&   _pickle_load_subprocessr{   w   s    IIIMMM:()D	dD		  Tfk$                              
#lfl3
 
 !!!!!s   AA
Ac                    t          |           |dz  }|                                rJ |                    d          5 }t          j        ||t          j                   d d d            n# 1 swxY w Y   |                                sJ t          t          dt          |          dd          }t          j	        t          j        |j                            }|j                                         |                     |                                           |                     |j        j                                                   t)          j        |           d S )Nzsinus.picklewb<   Agg)rq   
MPLBACKEND)timeout	extra_env)rT   existsru   r   r   r   r   r{   rx   rd   astliteral_evalstdoutre   rf   r;   rg   rh   ri   rj   r   rk   )rl   rO   tmp_pathfpfileproc
loaded_figs          r&    test_pickle_load_from_subprocessr      sw    #7+++	N	"Byy{{	 <$GT6#:;;;< < < < < < < < < < < < < < <99;; '*2wweDD  D c.t{;;<<JZ7799:::j'0<<>>???Ijs    !A--A14A1c                     t          j        d          } t                      }t          j        | |t          j                   t          j        d           t           j        j        j	        i k    sJ t          j
        |                                          } t           j        j        j	        i k    sJ |                                 dk    sJ d S )Nza labelall)r   r   r   r   r   r   rk   _pylab_helpersGcffigsrd   	getbuffer	get_label)r$   bufs     r&   test_gcfr      s    
*Y

C
))C
KS&1222Ie!&",,,,
,s}}
'
'C!&",,,,==??i''''''r(   c                     ddl m}  t          j                    } | |          }|                    ddd          }|                    g dg d           t          j        |t                      t          j	                   d S )Nr   )FigureCanvasPdfr.   )r.   r0   r-   )
matplotlib.backends.backend_pdfr   mfigureFigureadd_subplotr   r   r   r   r   )r   r$   _r%   s       r&   test_no_pyplotr      s    ??????
.

CA	Aq	!	!BGGIIIyyy!!!
KWYY 788888r(   c                  n    ddl m}   | ddd          }t          j        |t	                                 d S )Nr   )RendererAggr         )matplotlib.backends.backend_aggr   r   r   r   )r   ri   s     r&   test_rendererr      sC    ;;;;;;{2r2&&H
K'))$$$$$r(   c                  X   ddl m}   | d          }|j        j        }|                    ddd          }|                    t          j        d                              dd                     |j        	                                 t          j        |t                                 d S )Nr   )new_figure_manageri  r.      r-   r3   )r   r   re   r   r   rF   r   r   r>   rf   r   r   r   )r   managerr$   r%   s       r&   
test_imager      s     CBBBBB  &&G
.
C	Aq	!	!BIIbimm##Aq))***N
KWYYr(   c                      t          j        d           t          j                    } t          j        |           }t          j        |           t          j                     d S )NT)r   )r   r   gcfr   ra   rd   rf   )r$   pfs     r&   
test_polarr      sN    Kd
'))C	c		B
LHJJJJJr(   c                       e Zd Zd ZdS )TransformBlobc                 2   t          j                    | _        t          j                    | _        t          j        | j        | j                  | _        t          j        | j                  | _        t          j        | j        | j                  | _        d S N)	mtransformsIdentityTransformidentity	identity2CompositeGenericTransform	compositeTransformWrapperwrapper
composite2)selfs    r&   __init__zTransformBlob.__init__   sx    #577$688$>MN  #3DNCC%?LM r(   N)__name__
__module____qualname__r   r[   r(   r&   r   r      s#            r(   r   c                  z   t                      } t          j        |           }~ t          j        |          } | j        j        | j        k    sJ d | j        j                                        D             | j	        gk    sJ | j        j
        | j        j
        k    sJ | j        j        | j        j        k    sJ d S )Nc                 "    g | ]} |            S r[   r[   )r\   rS   s     r&   r`   z"test_transform.<locals>.<listcomp>   s    777AAACC777r(   )r   r   ra   rd   r   _childr   _parentsvaluesr   
input_dimsoutput_dims)objr   s     r&   test_transformr      s    
//C	c		B
,r

C;....77-4466777CN;KKKKK;!S]%=====;"cm&???????r(   c                      t          d          } 	 t          j        t          j        |                      d S # t          $ r t          d            w xY w)Nr0   z!rrulewrapper pickling test failed)r   r   rd   ra   RecursionErrorrw   )rs    r&   test_rrulewrapperr      s]    QAV\!__%%%%%   1222s	   &9 Ac                     t          j        dd          \  } }t          j        t          j        |                     } | j        d                             dd           | j        d                                         dk    sJ d S )	Nr0   T)sharexr   r   r   r.   )r   r   )r   subplotsr   rd   ra   r   rH   get_xlim)r$   axss     r&   test_sharedr      sx    |Ad+++HC
,v|C((
)
)CHQKR   8A;!!X------r(   c                     t          j                    \  } }|                    g d           |                    dt          j        t          j        f           t          j        t          j	        |                      d S )N)皙?r   333333?r   top)	functions)
r   r   
inset_axessecondary_xaxisr   squaresqrtr   rd   ra   r#   s     r&   test_inset_and_secondaryr      sl    lnnGCMM"""###uBG(<===
Lc""#####r(   cmapc                 .    t          j        |            d S r   )r   ra   )r   s    r&   	test_cmapr     s    
Lr(   c                      t          j                    } | j        J t                      }t	          j        | |           |                    d           t	          j        |          }|j        J d S )Nr   )r   r   re   r   r   r   seekrv   )r$   outfig2s      r&   test_unpickle_canvasr   	  sj    
.

C:!!!
))C
KSHHQKKK;sD;"""""r(   c                      t          j        g d          } t          t          j        t          j        |                               t           j        k    sJ d S )N)r   r   r.   r.   )r	   	host_axestyper   rd   ra   HostAxes)r%   s    r&   test_mpl_toolkitsr     sL    		 	.	.BV\"--..//=3IIIIIIIr(   c                      t          t          j        t          j        t          j                                                                      t          j        j        k    sJ d S r   )r   r   rd   ra   mplcolorsLogNormr[   r(   r&   test_standard_normr     sU    V\#**<*<*>*>??@@AA:     r(   c                     t          j                            t           j        j        t           j        j                              } t          t          j        t          j	        |                               t          |           k    sJ d S r   )
r   r   make_norm_from_scalescale
LogitScale	Normalizer   r   rd   ra   )logit_norm_instances    r&   test_dynamic_normr     s}    *99	cj24 4 6 6V\*=>>??@@#$$% % % % % %r(   c                      t          j        ddgd          \  } t          j        t          j        t          |                                d S )Nr   r.   T)picker)r   r   r   rd   ra   r   )lines    r&   test_vertexselectorr   $  sD    HaVD)))ED
LnT223344444r(   c                  `   t          j                                                    } |                     g d           |                     ddg           t          j        t          j        |                     } |                     ddg          \  }|                                dk    sJ d S )N)cmrP   k)r   r.   r0   r-   r3   r   )	r   r   r   set_prop_cycler   r   rd   ra   	get_color)r%   ls     r&   test_cyclerr   )  s    		!	!	#	#B,,,---GGQFOOO	fl2&&	'	'B	!QBA;;==Cr(   ):ior   r   r   rb   numpyr   pytest
matplotlibr   r   matplotlib.testingr   matplotlib.testing.decoratorsr   matplotlib.datesr   matplotlib.linesr   matplotlib.pyplotpyplotr   matplotlib.transforms
transformsr   matplotlib.figurer   r   mpl_toolkits.axes_grid1r	   r'   rT   stylecontextro   r{   r   r   r   r   r   r   r   r   r   r   r   markparametrize
_colormapsr   r   r   r   r   r   r   r   r[   r(   r&   <module>r     s	         



                     4 4 4 4 4 4 = = = = = = ) ) ) ) ) ) + + + + + +       + + + + + + # # # # # # 1 1 1 1 1 19 9 960 0 0f 9(((  )( $	" 	" 	" 9(((  )( 4( ( (9 9 9% % %	  	  	           @ @ @  . . .$ $ $ !5!5!7!788  98# # #J J J
  
% % %5 5 5
         r(   