o
    ¡:´a£  ã                   @   s  d dl m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„ Ze	d	gd
ddddd„ ƒZdd„ Zdd„ Zdd„ Zdd„ ZG dd„ dƒZdd„ Zdd„ Zdd„ Z d d!„ Z!ej" #d"ej$ %¡ ¡d#d$„ ƒZ&d%d&„ Z'd'd(„ Z(dS ))é    )ÚBytesION)Úcm)Úimage_comparison)Úrrulewrapper)Úparasite_axesc                  C   sè   t  ¡ } t | tƒ tj¡ t  d¡}t |tƒ tj¡ t jdd}t jt	 
d¡dd t  ¡  t |tƒ tj¡ t  ¡  t jt	 
d¡t	 
d¡d t t  ¡ tƒ tj¡ t  ¡ } t  ¡ }t  t	 
d¡¡ | d¡ t | tƒ tj¡ d S )	Néy   Úpolar)Z
projectioné
   Zfoobar©Zlabel)ÚxZheightÚlog)ÚpltÚfigureÚpickleÚdumpr   ÚHIGHEST_PROTOCOLÚsubplotÚaxesÚplotÚnpÚarangeÚlegendZbarZgcaZ
set_yscale©ÚfigÚax© r   ú>/usr/lib/python3/dist-packages/matplotlib/tests/test_pickle.pyÚtest_simple   s    

r   zmulti_pickle.pngTZmpl20gË¡E¶óý´?)Zremove_textZstyleZtolc                  C   s"  dt jd< t jddd} t  d¡ t d¡t d¡}}t d	dd
¡ dd¡ } }}t |d ¡}t  	ddd¡ t  
ttdƒƒ¡ t  	ddd¡ t j|ddgd t  ¡  t  	ddd¡ t  |¡ t  	ddd¡ t  |¡ t  	ddd¡ t  |¡ t  	ddd¡}| d	d¡ | d	d¡ t  ||||¡ t  	ddd¡}| d	d¡ | d	d¡ t  ||||¡ t  	ddd¡ t j||d dd t jdd t  	ddd¡ t j||d ddd tƒ }t | |tj¡ t  d¡ t jjj i ksòJ ‚| !d	¡ t "|¡} t jjj i ksJ ‚|  #¡ dksJ ‚d S ) NFzpcolormesh.snapzFigure with a label?)r	   é   )Zfigsizez!Can you fit any more in a figure?é   r	   r   éP   g333333ã¿é   é   é   z//Zooo)Zhatchesé   é   r   é   é	   z$x^2$r
   z
upper left)Úlocg      à¿gš™™™™™É?gš™™™™™Ù?)ZxerrZyerrÚall)$r   ZrcParamsr   Zsuptitler   r   ZlinspaceÚreshapeZsinr   r   ÚlistÚrangeZcontourfZcolorbarZ
pcolormeshÚimshowZpcolorÚset_xlimZset_ylimZ
streamplotZquiverZscatterr   Zerrorbarr   r   r   r   ÚcloseZ_pylab_helpersZGcfZfigsÚseekÚloadZ	get_label)r   r   ÚyÚdataÚuÚvr   Z	result_fhr   r   r   Útest_complete+   sL   







r6   c                  C   sT   ddl m}  t ¡ }| |ƒ}| ddd¡}| g d¢g d¢¡ t |tƒ tj	¡ d S )Nr   )ÚFigureCanvasPdfr"   )r"   r#   r!   )
Zmatplotlib.backends.backend_pdfr7   ÚmfigureÚFigureÚadd_subplotr   r   r   r   r   )r7   r   Ú_r   r   r   r   Útest_no_pyplotq   s   r<   c                  C   s*   ddl m}  | dddƒ}t |tƒ ¡ d S )Nr   )ÚRendererAggr	   é   é   )Úmatplotlib.backends.backend_aggr=   r   r   r   )r=   Zrendererr   r   r   Útest_renderer{   s   rA   c                  C   s^   ddl m}  | dƒ}|jj}| ddd¡}| t d¡ dd¡¡ |j 	¡  t
 |tƒ ¡ d S )Nr   )Únew_figure_manageriè  r"   é   r!   r$   )r@   rB   Úcanvasr   r:   r-   r   r   r*   Údrawr   r   r   )rB   Zmanagerr   r   r   r   r   Ú
test_image   s   
rF   c                  C   s4   t jdd t  ¡ } t | ¡}t |¡ t  ¡  d S )NT)r   )r   r   Zgcfr   ÚdumpsÚloadsrE   )r   Úpfr   r   r   Ú
test_polar   s
   

rJ   c                   @   s   e Zd Zdd„ ZdS )ÚTransformBlobc                 C   sJ   t  ¡ | _t  ¡ | _t  | j| j¡| _t  | j¡| _t  | j| j¡| _d S ©N)	ÚmtransformsZIdentityTransformÚidentityZ	identity2ZCompositeGenericTransformÚ	compositeZTransformWrapperÚwrapperÚ
composite2)Úselfr   r   r   Ú__init__–   s   

þ
þzTransformBlob.__init__N)Ú__name__Ú
__module__Ú__qualname__rS   r   r   r   r   rK   •   s    rK   c                  C   s|   t ƒ } t | ¡}~ t |¡} | jj| jksJ ‚dd„ | jj ¡ D ƒ| j	gks(J ‚| jj
| jj
ks2J ‚| jj| jjks<J ‚d S )Nc                 S   s   g | ]}|ƒ ‘qS r   r   )Ú.0r5   r   r   r   Ú
<listcomp>®   s    z"test_transform.<locals>.<listcomp>)rK   r   rG   rH   rP   Z_childrO   Z_parentsÚvaluesrQ   Z
input_dimsZoutput_dims)ÚobjrI   r   r   r   Útest_transform¥   s   

"r[   c                  C   s8   t dƒ} zt t | ¡¡ W d S  ty   tdƒ ‚ w )Nr#   z!rrulewrapper pickling test failed)r   r   rH   rG   ÚRecursionErrorÚprint)Úrr   r   r   Útest_rrulewrapper´   s   þr_   c                  C   sN   t jddd\} }t t | ¡¡} | jd  dd¡ | jd  ¡ dks%J ‚d S )	Nr#   T)Zsharexr   r	   r>   r"   )r	   r>   )r   Úsubplotsr   rH   rG   r   r.   Zget_xlim)r   Zaxsr   r   r   Útest_shared½   s   ra   c                  C   sD   t  ¡ \} }| g d¢¡ |jdtjtjfd t t 	| ¡¡ d S )N)çš™™™™™¹?rb   ç333333Ó?rc   Útop)Z	functions)
r   r`   Z
inset_axesZsecondary_xaxisr   ZsquareZsqrtr   rH   rG   r   r   r   r   Útest_inset_and_secondaryÄ   s   re   Úcmapc                 C   s   t  | ¡ d S rL   )r   rG   )rf   r   r   r   Ú	test_cmapË   s   rg   c                  C   sN   t  ¡ } | jd usJ ‚tƒ }t | |¡ | d¡ t |¡}|jd us%J ‚d S )Nr   )r8   r9   rD   r   r   r   r0   r1   )r   ÚoutZfig2r   r   r   Útest_unpickle_canvasÐ   s   

ri   c                  C   s0   t  g d¢¡} tt t | ¡¡ƒt jksJ ‚d S )N)r   r   r"   r"   )r   Z	host_axesÚtyper   rH   rG   ZHostAxes)r   r   r   r   Útest_mpl_toolkitsÚ   s   "rk   ))Úior   r   Znumpyr   ZpytestZ
matplotlibr   Zmatplotlib.testing.decoratorsr   Zmatplotlib.datesr   Zmatplotlib.pyplotZpyplotr   Zmatplotlib.transformsZ
transformsrM   Zmatplotlib.figurer   r8   Zmpl_toolkits.axes_grid1r   r   r6   r<   rA   rF   rJ   rK   r[   r_   ra   re   ZmarkZparametrizeZ_cmap_registryrY   rg   ri   rk   r   r   r   r   Ú<module>   s:    
ÿ
D
	

