
    G8c                     J   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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>                  jA                  d       edg      d               Z!d Z"ej>                  jA                  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\                  j_                  de	j`                  jc                               d        Z2d Z3d Z4d  Z5d! Z6d" Z7y)#    )BytesION)cm)subprocess_run_helper)check_figures_equal)rrulewrapper)VertexSelector)parasite_axesc                  H   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             |j                  d       t        j                  | t	               t        j
                         y )	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     >/usr/lib/python3/dist-packages/matplotlib/tests/test_pickle.pytest_simpler'      s%   
**,C
KKWY 7 78	S	B
KKGIv667	W	%BHHRYYr](+JJL
KKGIv667
 JJLGGbiimBIIbM2
KK	79f&=&=>
**,C	BHHRYYr]MM%
KKWY 7 78    c                    | j                  d       t        j                  |        t        j                  d       t	        j
                  d      t	        j
                  d      }}t	        j                  ddd      j                  dd      x}x}}t	        j                  |dz        }t        j                  ddd	       t        j                  t        t        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dd       t        j"                  |       t        j                  ddd      }|j%                  dd       |j'                  dd       t        j(                  ||||       t        j                  ddd      }|j%                  dd       |j'                  dd       t        j*                  ||||       t        j                  ddd       t        j,                  ||d
z  d       t        j.                  d       t        j                  ddd       t        j0                  ||dz  dd       y )N)r      z!Can you fit any more in a figure?   r   r   P   g333333         z//ooo)hatches      r*      	   z$x^2$r   z
upper left)locg      g?g?)xerryerr)set_size_inchesr   r   suptitler   r   linspacereshapesinr   r   listrangecontourfcolorbar
pcolormeshimshowpcolorset_xlimset_ylim
streamplotquiverscatterr   errorbar)fig_refr   ydatauvr%   s          r&   _generate_complete_test_figurerP   /   s   G$JJwLL45 99Q<2qA;;q"b)11"a88D81q
q4xA KK1aHHT%)_KK1aLLe}-LLNKK1aNN4KK1aJJtKK1aJJt	Q1	BKK1KK1NN1aA	Q1	BKK1KK1JJq!QKK1aKK16)JJ< KK1aLLAH3S1r(   defaultpng)
extensionsc                    t        |       t               }t        j                  ||t        j                         t        j
                  |j                               }|j                  j                          | j                  |j                                | j                  |j                  j                  j                                t        j                  |       y N)rP   r   r   r   r   loads	getbuffercanvasdrawr9   get_size_inchesfigimagerendererbuffer_rgbar   close)fig_testrK   pklloadeds       r&   test_completerb   ]   s     #7+
)C
KKf556\\#--/*F
MMV3356fmm,,88:;IIfr(   c                      dd l } dd l}| j                  d   }t        |d      5 } |j                  |      }d d d        t        t         |j                                     y # 1 sw Y   .xY w)Nr   PICKLE_FILE_PATHrb)osr   environopenloadprintstrdumps)rf   r   pathblobr$   s        r&   _pickle_load_subprocessro   m   sb    ::()D	dD	  Tfkk$  
#lfll3
 !   s   A$$A-c                    t        |       |dz  }|j                         rJ |j                  d      5 }t        j                  ||t        j
                         d d d        |j                         sJ t        t        ddt        |      i      }t        j                  t        j                  |j                              }|j                  j                          | j                  |j!                                | j#                  |j                  j$                  j'                                t)        j*                  |       y # 1 sw Y   xY w)Nzsinus.picklewb<   rd   )timeout	extra_env)rP   existsrh   r   r   r   r   ro   rk   rV   astliteral_evalstdoutrX   rY   r9   rZ   r[   r\   r]   r   r^   )r_   rK   tmp_pathfpfileproc
loaded_figs          r&    test_pickle_load_from_subprocessr~   y   s     #7+	N	"Byy{?	 <$GT6#:#:;<99;; %s2w/D c..t{{;<JZ779:j''00<<>?IIj#< <s   &EEc                     t        j                  d      } t               }t        j                  | |t        j
                         t        j                  d       t         j                  j                  j                  i k(  sJ t        j                  |j                               } t         j                  j                  j                  i k7  sJ | j                         dk(  sJ y )Nza labelall)r   r   r   r   r   r   r^   _pylab_helpersGcffigsrV   rW   	get_label)r$   bufs     r&   test_gcfr      s    
**Y
C
)C
KKS&112IIe!!&&",,,
,,s}}
'C!!&&",,,==?i'''r(   c                      ddl m}  t        j                         } | |      }|j	                  ddd      }|j                  g dg d       t        j                  |t               t        j                         y )Nr   )FigureCanvasPdfr.   )r.   r/   r-   )
matplotlib.backends.backend_pdfr   mfigureFigureadd_subplotr   r   r   r   r   )r   r$   _r%   s       r&   test_no_pyplotr      sS    ?
..
CA	Aq	!BGGIy!
KKWY 7 78r(   c                  `    ddl m}   | ddd      }t        j                  |t	                      y )Nr   )RendererAggr         )matplotlib.backends.backend_aggr   r   r   r   )r   r\   s     r&   test_rendererr      s#    ;2r2&H
KK')$r(   c                  J   ddl m}   | d      }|j                  j                  }|j	                  ddd      }|j                  t        j                  d      j                  dd             |j                  j                          t        j                  |t                      y )Nr   )new_figure_manageri  r.      r-   r2   )r   r   rX   r   r   rC   r   r   r<   rY   r   r   r   )r   managerr$   r%   s       r&   
test_imager      st     C &G
..

C	Aq	!BIIbiim##Aq)*NN
KKWYr(   c                      t        j                  d       t        j                         } t        j                  |       }t        j
                  |       t        j                          y )NT)r   )r   r   gcfr   rl   rV   rY   )r$   pfs     r&   
test_polarr      s<    KKd
'')C	c	B
LLHHJr(   c                       e Zd Zd Zy)TransformBlobc                 l   t        j                         | _        t        j                         | _        t        j                  | j                  | j                        | _        t        j                  | j
                        | _        t        j                  | j                  | j                        | _        y rU   )	mtransformsIdentityTransformidentity	identity2CompositeGenericTransform	compositeTransformWrapperwrapper
composite2)selfs    r&   __init__zTransformBlob.__init__   sz    #557$668$>>MMNN #33DNNC%??LLMMr(   N)__name__
__module____qualname__r    r(   r&   r   r      s    r(   r   c                     t               } t        j                  |       }~ t        j                  |      } | j                  j
                  | j                  k(  sJ | j                  j                  j                         D cg c]	  } |        c}| j                  gk(  sJ | j                  j                  | j                  j                  k(  sJ | j                  j                  | j                  j                  k(  sJ y c c}w rU   )r   r   rl   rV   r   _childr   _parentsvaluesr   
input_dimsoutput_dims)objr   rO   s      r&   test_transformr      s    
/C	c	B
,,r
C;;...--4467AAC7CNN;KKKK;;!!S]]%=%====;;""cmm&?&???? 8s   Dc                      t        d      } 	 t        j                  t        j                  |              y # t        $ r t        d        w xY w)Nr/   z!rrulewrapper pickling test failed)r   r   rV   rl   RecursionErrorrj   )rs    r&   test_rrulewrapperr      s?    QAV\\!_% 12s	   (6 Ac                  
   t        j                  dd      \  } }t        j                  t        j                  |             } | j
                  d   j                  dd       | j
                  d   j                         dk(  sJ y )	Nr/   T)sharexr   r   r   r.   )r   r   )r   subplotsr   rV   rl   r   rE   get_xlim)r$   axss     r&   test_sharedr      sd    ||Ad+HC
,,v||C(
)CHHQKR 88A;!X---r(   c                  
   t        j                         \  } }|j                  g d       |j                  dt        j
                  t        j                  f       t        j                  t        j                  |              y )N)皙?r   333333?r   top)	functions)
r   r   
inset_axessecondary_xaxisr   squaresqrtr   rV   rl   r#   s     r&   test_inset_and_secondaryr      sS    llnGCMM"#uBGG(<=
LLc"#r(   cmapc                 .    t        j                  |        y rU   )r   rl   )r   s    r&   	test_cmapr      s    
LLr(   c                      t        j                         } | j                  J t               }t	        j
                  | |       |j                  d       t	        j                  |      }|j                  J y )Nr   )r   r   rX   r   r   r   seekri   )r$   outfig2s      r&   test_unpickle_canvasr      s\    
..
C::!!!
)C
KKSHHQK;;sD;;"""r(   c                      t        j                  g d      } t        t        j                  t        j
                  |                   t         j                  k(  sJ y )N)r   r   r.   r.   )r	   	host_axestyper   rV   rl   HostAxes)r%   s    r&   test_mpl_toolkitsr   	  s=    		 	 	.BV\\"-./=3I3IIIIr(   c                      t        t        j                  t        j                  t        j
                  j                                           t        j
                  j                  k(  sJ y rU   )r   r   rV   rl   mplcolorsLogNormr   r(   r&   test_standard_normr     sE    V\\#***<*<*>?@A::  r(   c                  *   t        j                  j                  t         j                  j                  t         j                  j
                               } t        t        j                  t        j                  |                   t        |       k(  sJ y rU   )
r   r   make_norm_from_scalescale
LogitScale	Normalizer   r   rV   rl   )logit_norm_instances    r&   test_dynamic_normr     sh    **99		cjj224 6V\\*=>?@#$% % %r(   c                      t        j                  ddgd      \  } t        j                  t        j                  t        |                    y )Nr   r.   T)picker)r   r   r   rV   rl   r   )lines    r&   test_vertexselectorr     s2    HHaVD)ED
LLnT234r(   )8ior   rv   r   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'   rP   stylecontextrb   ro   r~   r   r   r   r   r   r   r   r   r   r   markparametrize
_colormapsr   r   r   r   r   r   r   r   r(   r&   <module>r      s*    
      4 = ) +  + # 196+2\ 9( ) 	" 9( ) 4(9%	   @.$ !5!5!78 9#J

%5r(   