o
    u€#g‡%  ã                   @   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Zd dl	Z	d dl
Zd dl
mZ d dlmZ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 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%„ Z0d&d'„ Z1d(d)„ Z2e	j3 4d*ej5 6¡ ¡d+d,„ ƒZ7d-d.„ Z8d/d0„ Z9d1d2„ Z:d3d4„ Z;d5d6„ Z<d7d8„ Z=d9d:„ Z>e	j3j?d;ej@v sîd<ej@v oûejAd=koûejBdd>… d?k d@dAdBdC„ ƒZCdS )Dé    )ÚBytesION)Úcm)Úsubprocess_run_helperÚis_ci_environment)Úcheck_figures_equal)Úrrulewrapper)ÚVertexSelector)Úaxes_dividerÚ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)Ú
projectioné
   Úfoobar©Úlabel)ÚxÚheightÚlog)ÚpltÚfigureÚpickleÚdumpr   ÚHIGHEST_PROTOCOLÚsubplotÚaxesÚplotÚnpÚarangeÚlegendÚbarÚgcaÚ
set_yscale©ÚfigÚax© r&   ú/var/www/static.ux5.de/https/Moving-Object-Detection-with-OpenCV/env/lib/python3.10/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
¡ t 	ddd¡ tj|ddgd t ¡  t 	ddd¡ t |¡ t 	ddd¡ t |¡ t d¡ 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 tjdd |  d¡}|d  d	d¡ |d	  d	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š™™™™™Ù?z$-.5 x$)ÚxerrÚyerrr   T)Ú	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Ú
subfiguresÚsubplotsÚalign_ylabels)Úfig_refr   ÚyÚdataÚuÚvr%   Úsubfigsr&   r&   r'   Ú_generate_complete_test_figure2   sJ   








rV   ÚdefaultÚpng)Ú
extensionsc                 C   st   t |ƒ t |tj¡}ddd„ t |¡D ƒvsJ ‚t |¡}|j ¡  |  	| 
¡ ¡ |  |jj ¡ ¡ t |¡ d S )NÚFigureCanvasAggc                 S   s   g | ]\}}}|‘qS r&   r&   )Ú.0ÚopÚargÚposr&   r&   r'   Ú
<listcomp>t   s    z!test_complete.<locals>.<listcomp>)rV   r   Údumpsr   ÚpickletoolsÚgenopsÚloadsÚcanvasÚdrawr:   Úget_size_inchesÚfigimageÚrendererÚbuffer_rgbar   Úclose)Úfig_testrP   ÚpklÚloadedr&   r&   r'   Útest_completej   s   

rn   c                  C   sd   dd l } dd l}| jd }t|dƒ}| |¡}W d   ƒ n1 s"w   Y  tt| |¡ƒƒ d S )Nr   ÚPICKLE_FILE_PATHÚrb)Úosr   ÚenvironÚopenÚloadÚprintÚstrr`   )rq   r   ÚpathÚblobr$   r&   r&   r'   Ú_pickle_load_subprocess~   s   
ÿry   c                 C   sÄ   t |ƒ |d }| ¡ rJ ‚| d¡}t ||tj¡ W d   ƒ n1 s&w   Y  | ¡ s1J ‚ttdt|ƒddœd}t 	t
 |j¡¡}|j ¡  |  | ¡ ¡ |  |jj ¡ ¡ t |¡ d S )Nzsinus.pickleÚwbé<   ÚAgg)ro   Ú
MPLBACKEND©ÚtimeoutÚ	extra_env)rV   Úexistsrs   r   r   r   r   ry   rv   rc   ÚastÚliteral_evalÚstdoutrd   re   r:   rf   rg   rh   ri   r   rj   )rk   rP   Útmp_pathÚfpÚfileÚprocÚ
loaded_figr&   r&   r'   Ú test_pickle_load_from_subprocessŠ   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s6J ‚d S )Nza labelÚall)r   r   r   r   r   r   rj   Ú_pylab_helpersÚGcfÚfigsrc   Ú	getbufferÚ	get_label)r$   Úbufr&   r&   r'   Útest_gcf¦   s   

r’   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,   )
Úmatplotlib.backends.backend_pdfr“   ÚmfigureÚFigureÚadd_subplotr   r   r   r   r   )r“   r$   Ú_r%   r&   r&   r'   Útest_no_pyplot±   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š   rh   r&   r&   r'   Útest_renderer»   s   rž   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,   r2   )r   rŸ   rd   r   r—   rE   r   r   r=   re   r   r   r   )rŸ   Úmanagerr$   r%   r&   r&   r'   Ú
test_imageÁ   s   
r¢   c                  C   s4   t jdd t  ¡ } t | ¡}t |¡ t  ¡  d S )NT)r   )r   r   Úgcfr   r`   rc   re   )r$   Úpfr&   r&   r'   Ú
test_polarÍ   s
   

r¥   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)	ÚmtransformsÚIdentityTransformÚidentityÚ	identity2ÚCompositeGenericTransformÚ	compositeÚTransformWrapperÚwrapperÚ
composite2)Úselfr&   r&   r'   Ú__init__Ö   s   

þ
þzTransformBlob.__init__N)Ú__name__Ú
__module__Ú__qualname__r²   r&   r&   r&   r'   r¦   Õ   s    r¦   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&   )r[   rT   r&   r&   r'   r_   î   s    z"test_transform.<locals>.<listcomp>)r¦   r   r`   rc   r¯   Ú_childr­   Ú_parentsÚvaluesr°   Ú
input_dimsÚoutput_dims)Úobjr¤   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   rc   r`   ÚRecursionErrorru   )Ú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)Úsharexr   r   r›   r-   )r   r›   )r   rN   r   rc   r`   r   rG   Úget_xlim)r$   Ú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)Ú	functions)
r   rN   Ú
inset_axesÚsecondary_xaxisr   ÚsquareÚsqrtr   rc   r`   r#   r&   r&   r'   Útest_inset_and_secondary  s   rÌ   Úcmapc                 C   s   t  | ¡ d S r§   )r   r`   )rÍ   r&   r&   r'   Ú	test_cmap  s   rÎ   c                  C   sN   t  ¡ } | jd usJ ‚tƒ }t | |¡ | d¡ t |¡}|jd us%J ‚d S )Nr   )r•   r–   rd   r   r   r   Úseekrt   )r$   ÚoutÚfig2r&   r&   r'   Útest_unpickle_canvas  s   

rÒ   c                  C   s:   t  g d¢¡} t | ¡ tt t | ¡¡ƒt jksJ ‚d S )N)r   r   r-   r-   )	r
   Ú	host_axesr	   Úmake_axes_area_auto_adjustableÚtyper   rc   r`   Ú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   rc   r`   ÚmplÚcolorsÚ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sJ ‚d S r§   )
rÙ   rÚ   Úmake_norm_from_scaleÚscaleÚ
LogitScaleÚ	NormalizerÕ   r   rc   r`   )Ú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)Úpicker)r   r   r   rc   r`   r   )Úliner&   r&   r'   Útest_vertexselector,  s   rå   c                  C   s^   t  ¡  ¡ } | jg d¢d |  ddg¡ t t | ¡¡} |  ddg¡\}| ¡ dks-J ‚d S )N)ÚcÚmrQ   Úk)ræ   r-   r/   r,   r2   rç   )	r   r   r—   Úset_prop_cycler   r   rc   r`   Ú	get_color)r%   Úlr&   r&   r'   Útest_cycler1  s   rì   c                  C   s$   t  ¡  ¡ } t tj | d¡¡ d S )NÚbutton)r   r   r—   r   r`   rÙ   ÚwidgetsÚButtonr×   r&   r&   r'   Ú_test_axeswidget_interactive<  s   rð   ÚTF_BUILDÚGITHUB_ACTIONÚdarwinr/   )r,   é   z%Tk version mismatch on Azure macOS CI)Úreasonc                   C   s    t ttƒ rdndddid d S )Néx   r›   r}   Útkaggr~   )r   rð   r   r&   r&   r&   r'   Útest_axeswidget_interactiveA  s
   
ýrø   )DÚior   r‚   rq   Úsysr   ra   Únumpyr   ÚpytestÚ
matplotlibrÙ   r   Úmatplotlib.testingr   r   Úmatplotlib.testing.decoratorsr   Úmatplotlib.datesr   Úmatplotlib.linesr   Úmatplotlib.pyplotÚpyplotr   Úmatplotlib.transformsÚ
transformsr¨   Úmatplotlib.figurer   r•   Úmpl_toolkits.axes_grid1r	   r
   r(   rV   ÚstyleÚcontextrn   ry   rŠ   r’   r™   rž   r¢   r¥   r¦   r¼   r¿   rÃ   rÌ   ÚmarkÚparametrizeÚ
_colormapsr¸   rÎ   rÒ   rØ   rÜ   râ   rå   rì   rð   Úxfailrr   ÚplatformÚversion_inforø   r&   r&   r&   r'   Ú<module>   sl    
8



	

ÿý