a
    s=ic  ã                   @   s–  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	d
„ Zdd„ Zej  d¡edgddd„ ƒƒZ!dd„ Z"ej  d¡edgddd„ ƒƒZ#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	j0 1¡ ¡d+d,„ ƒZ2d-d.„ Z3d/d0„ Z4d1d2„ Z5d3d4„ Z6d5d6„ Z7dS )7é    )ÚBytesION)Úcm)Úsubprocess_run_helper)Úcheck_figures_equal)Úrrulewrapper)ÚVertexSelector)Ú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©Úlabel)ÚxÚheightÚlog)ÚpltÚfigureÚpickleÚdumpr   ÚHIGHEST_PROTOCOLÚsubplotÚaxesÚplotÚnpÚarangeÚlegendÚbarZgcaZ
set_yscale©ÚfigÚax© r    úm/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/matplotlib/tests/test_pickle.pyÚtest_simple   s     

r"   c                 C   s²  |   d¡ t | ¡ 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 d S )N)r   é   z!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)Úset_size_inchesr   r   Zsuptitler   r   ZlinspaceÚreshapeÚsinr   r   ÚlistÚrangeZcontourfZcolorbarZ
pcolormeshÚimshowZpcolorÚset_xlimZset_ylimZ
streamplotZquiverZscatterr   Zerrorbar)Úfig_refr   ÚyÚdataÚuÚvr   r    r    r!   Ú_generate_complete_test_figure/   s<    





r:   ÚdefaultZpng)Ú
extensionsc                 C   sd   t |ƒ tƒ }t ||tj¡ t | ¡ ¡}|j ¡  |  	| 
¡ ¡ |  |jj ¡ ¡ t |¡ d S ©N)r:   r   r   r   r   ÚloadsÚ	getbufferÚcanvasÚdrawr.   Úget_size_inchesÚfigimageÚrendererÚbuffer_rgbar   Úclose)Úfig_testr5   ZpklZloadedr    r    r!   Útest_complete]   s    
rH   c                  C   sd   dd l } dd l}| jd }t|dƒ}| |¡}W d   ƒ n1 sD0    Y  tt| |¡ƒƒ d S )Nr   ÚPICKLE_FILE_PATHÚrb)Úosr   ÚenvironÚopenÚloadÚprintÚstrÚdumps)rK   r   ÚpathZblobr   r    r    r!   Ú_pickle_load_subprocessm   s    
(rS   c                 C   sÂ   t |ƒ |d }| ¡ rJ ‚| d¡ }t ||tj¡ W d   ƒ n1 sL0    Y  | ¡ sbJ ‚ttddt|ƒid}t 	t
 |j¡¡}|j ¡  |  | ¡ ¡ |  |jj ¡ ¡ t |¡ d S )Nzsinus.pickleÚwbé<   rI   )ÚtimeoutZ	extra_env)r:   ÚexistsrM   r   r   r   r   rS   rP   r>   ÚastÚliteral_evalÚstdoutr@   rA   r.   rB   rC   rD   rE   r   rF   )rG   r5   Ztmp_pathÚfpÚfileÚprocZ
loaded_figr    r    r!   Ú test_pickle_load_from_subprocessy   s     .
ý
r^   c                  C   sp   t  d¡} tƒ }t | |tj¡ t  d¡ t jjj	i ks<J ‚t 
| ¡ ¡} t jjj	i ks\J ‚|  ¡ dkslJ ‚d S )Nza labelÚall)r   r   r   r   r   r   rF   Z_pylab_helpersZGcfZfigsr>   r?   Z	get_label)r   Úbufr    r    r!   Útest_gcf•   s    

ra   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_pdfrb   ÚmfigureÚFigureÚadd_subplotr   r   r   r   r   )rb   r   Ú_r   r    r    r!   Útest_no_pyplot    s    rg   c                  C   s*   ddl m}  | dddƒ}t |tƒ ¡ d S )Nr   )ÚRendererAggr   é   é   )Úmatplotlib.backends.backend_aggrh   r   r   r   )rh   rD   r    r    r!   Útest_rendererª   s    rl   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)   )rk   rm   r@   r   re   r3   r   r   r/   rA   r   r   r   )rm   Úmanagerr   r   r    r    r!   Ú
test_image°   s    
rp   c                  C   s4   t jdd t  ¡ } t | ¡}t |¡ t  ¡  d S )NT)r
   )r   r   Zgcfr   rQ   r>   rA   )r   Úpfr    r    r!   Ú
test_polar¼   s
    

rr   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 r=   )	ÚmtransformsZIdentityTransformÚidentityZ	identity2ZCompositeGenericTransformÚ	compositeZTransformWrapperÚwrapperÚ
composite2)Úselfr    r    r!   Ú__init__Å   s    

þþzTransformBlob.__init__N)Ú__name__Ú
__module__Ú__qualname__rz   r    r    r    r!   rs   Ä   s   rs   c                  C   s|   t ƒ } t | ¡}~ t |¡} | jj| jks.J ‚dd„ | jj ¡ D ƒ| j	gksPJ ‚| jj
| jj
ksdJ ‚| jj| jjksxJ ‚d S )Nc                 S   s   g | ]
}|ƒ ‘qS r    r    )Ú.0r9   r    r    r!   Ú
<listcomp>Ý   ó    z"test_transform.<locals>.<listcomp>)rs   r   rQ   r>   rw   Ú_childrv   Ú_parentsÚvaluesrx   Z
input_dimsZoutput_dims)Úobjrq   r    r    r!   Útest_transformÔ   s    

"r…   c                  C   s>   t dƒ} zt t | ¡¡ W n ty8   tdƒ ‚ Y n0 d S )Nr(   z!rrulewrapper pickling test failed)r   r   r>   rQ   ÚRecursionErrorrO   )Ú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sJJ ‚d S )	Nr(   T)Zsharexr   r   ri   r'   )r   ri   )r   Úsubplotsr   r>   rQ   r   r4   Zget_xlim)r   Zaxsr    r    r!   Útest_sharedì   s    rŠ   c                  C   sD   t  ¡ \} }| g d¢¡ |jdtjtjfd t t 	| ¡¡ d S )N)çš™™™™™¹?r‹   ç333333Ó?rŒ   Útop)Z	functions)
r   r‰   Z
inset_axesZsecondary_xaxisr   ZsquareÚsqrtr   r>   rQ   r   r    r    r!   Útest_inset_and_secondaryó   s    r   Úcmapc                 C   s   t  | ¡ d S r=   )r   rQ   )r   r    r    r!   Ú	test_cmapú   s    r‘   c                  C   sN   t  ¡ } | jd usJ ‚tƒ }t | |¡ | d¡ t |¡}|jd usJJ ‚d S )Nr   )rc   rd   r@   r   r   r   ÚseekrN   )r   ÚoutZfig2r    r    r!   Útest_unpickle_canvasÿ   s    

r”   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   r>   rQ   ZHostAxes)r   r    r    r!   Útest_mpl_toolkits	  s    r–   c                   C   s*   t t t tj ¡ ¡¡ƒtjjks&J ‚d S r=   )r•   r   r>   rQ   ÚmplÚcolorsZLogNormr    r    r    r!   Útest_standard_norm  s    ÿr™   c                  C   s<   t j t jjt jj¡ƒ } tt t 	| ¡¡ƒt| ƒks8J ‚d S r=   )
r—   r˜   Zmake_norm_from_scaleÚscaleZ
LogitScaleZ	Normalizer•   r   r>   rQ   )Zlogit_norm_instancer    r    r!   Útest_dynamic_norm  s    ÿÿr›   c                  C   s,   t jddgdd\} t t t| ƒ¡¡ d S )Nr   r'   T)Zpicker)r   r   r   r>   rQ   r   )Úliner    r    r!   Útest_vertexselector  s    r   )8Úior   rX   r   Únumpyr   ZpytestZ
matplotlibr—   r   Zmatplotlib.testingr   Zmatplotlib.testing.decoratorsr   Zmatplotlib.datesr   Zmatplotlib.linesr   Zmatplotlib.pyplotZpyplotr   Zmatplotlib.transformsZ
transformsrt   Zmatplotlib.figurer   rc   Zmpl_toolkits.axes_grid1r   r"   r:   ÚstyleÚcontextrH   rS   r^   ra   rg   rl   rp   rr   rs   r…   rˆ   rŠ   r   ÚmarkZparametrizeZ
_colormapsrƒ   r‘   r”   r–   r™   r›   r   r    r    r    r!   Ú<module>   sP   .




	

